Using Git

From Apertium
Revision as of 06:21, 2 March 2018 by Shardulc (talk | contribs) (Add migration stuff)
Jump to navigation Jump to search

Learning to use git

If you have not used git before, or are uncomfortable with using git, these resources can help you:

If you have further questions:

Learning to use GitHub

If you have not used GitHub before, or are uncomfortable with using GitHub, these resources can help you:

The official GitHub documentation is extensive and helpful. Specific questions can be answered by #In-house git help.

Avoiding git completely

For some reason, if you don't like git or don't want to learn git or are unable to learn git, you can avoid using git completely for all GitHub repositories. You will simply need to perform a fresh SVN checkout with the correct URL and you can continue using the same SVN commands and workflow that you are used to. This page explains how to do this.

Advanced git commands

Removing/undoing all changes since the last commit

git stash

What this does: If you've added new files to be committed, the're "unadded" (but not deleted); if you've made changes to tracked files, the changes are removed so they look like what they were in the last commit. (Bonus point: changes removed with stash can be re-added if you change your mind with git stash pop.)

This only works on all changes (you can't stash a specific file).

Reverting your branch to the state of a remote branch

If on branch master, you want to get your repo to what the remote master looks like:

git reset --hard origin/master

Use case: say you're in the master branch, and have done a bunch of local commits/merges that you haven't pushed. Now you're stuck somehow, maybe you've got a merge conflict or something and you can't figure out the damn commands to get out of it all. You just want your repo to look like you just checked it out. Then you can run this command. It'll work in the middle of merge conflicts, with staged-but-not-committed files, etc.

If you reset to origin/master from some other branch, that branch will now be at the same commit as the remote master (and any other committed changes in that branch will be lost).

If you're on branch somefeature and want to revert to the remote somefeature, then this is the command:

git reset --hard origin/somefeature

Removing/undoing your changes to a certain file / path

 git checkout -- <path>

If "path" is ".", you undo all your changes to version controlled files in that directory and sub-directories:

 git checkout -- .

If you've first done git add (to "stage your changes", so some file is listed under Changes to be committed), you first need to do git reset to unstage the changes, then checkout in case you had changes to files already tracked. So to do that for the whole dir:

git reset HEAD .
git checkout -- .

Merge conflict: Throw away local changes

 git checkout master <path>
 git commit
 git merge master

(The last command should now do nothing, just say you're fully merged.)

In-house git help

Method 1: IRC


Method 2: Email

  • user Shardulc (talk), email <shardul DOT chiplunkar AT gmail DOT com>


Method 3: Contact via mailing lists, especially apertium-stuff