Revision as of 01:50, 2 November 2009

Contents

Setting up Git

First, you should tell Git your name and email address. These information will be shown in the log and in commits. Also, you should allow color in Git. There are other color-related features, but this tutorial is just about basics.

You see that Git noticed the changes in the file. "git commit -a" commits all changes in the repository. Note: This command does not add newly created files.

Branches and merging are cheap in Git

git branch shows you the branches of the repository, the one with the '*' is the active one. So let us create a new branch called "bugfix-branch" and assume we want to fix a branch there. After this fix (in this case the new file) we will merge back all the hard work into the master branch.

If you would have edited "testfile" in the bugfix-branch, then git would automatically try to merge the contents of "testfile" in the bugfix-branch with the contents of "testfile" in the master branch. Sometimes this can cause a merge conflict. In that case you have to manually edit the "testfile" in the master branch, and afterwards you do a "git commit -a" to complete the merge. Git indicates the conflicting lines in the file itself.

Handling local changes

git-svn cannot sync with SVN when you have local, uncommited changes. For that you are using git stash. That command move the local changes on a stack so that you can sync. After the sync you re-apply them to you Git tree and clear the stack. Very handy feature in many situations! Just do this:

git stash
git svn rebase
git stash apply
git stash clear

If you have local changes which you would like to revert use the following command. It will revert all local, uncommited changes.