GIT for the quick
These are just some quick help topics that should clear up some confusion while moving from the svn workflow. The important thing to remember that your "working copy" is actually contains a full-featured repository. You should also note that there are no revision numbers, but each change has a SHA-hash to identify it.
How do I set my git username?
Always set your username and email so that github can can connect the checkins to your account.
git config --global user.name "mad voo" git config --global user.email mad.vooo@gmail.com
How do I update my local copy?
Simply run this in your working directory:
git pull
How do I commit to GitHub?
Committing works a bit different: Since you have a "local" repository, changes will be first checked in to that. To commit to your local repository, you just do:
git commit -a -m 'message'
and the change goes to your local history. The '-a' switch tells git to automatically commit all files that have changed. (It will not commit new files, you have to git add them).
To get your changes to GitHub, do this:
git push
All your local changes will be put to GitHub?.
Hint: As long as your changes are only commited local, you can undo them and change the history. Once it's up on GitHub?, it permanent.
What about the branches?
Branches are powerful, but not completely straightforward, since there are two types of branches:
- The original "remote" branches of the original repository on GitHub?. You don't work with them directly.
- Local branches that only exist in your repository
In order to use different branch from the Talia repository, you have to create a local version of it. The local version is "connected" to the original branch so that all changes you git push will end up in the original branch.
Here is an example:
git checkout --track -b discovery origin/discovery
It tells git to create a local branch "discovery" which is connected to "origin/discovery", which is the discovery branch of the GitHub? repository. All changes you make in your local "discovery" branch will go to the "discovery" branch on GitHub?.
Usually you will set this up one time and then forget about it; you'll only work with the local branches.
What about local branches?
You can see all your local branches using
git branch
and you can switch to another branch using
git checkout <branch>
The nice thing is that you can create a new branch at any time, just say
git checkout <new branch>
and you will branch off the branch you have currently checked out. You can create branches and switch as you like. Local branches can be easily removed and since they don't go to the central repository, you are completely free in using them.
How do I merge branches?
The best feature of branches is that, unlike in svn, merging actually works. Just say
git merge <other_branch>
and all changes from other_branch will be merged into the currently checked-out branch. You can merge as often as you like.
If you want to have just one change from another branch, just say
git cherry-pick <commit>
which will add the commit to your current branch. This adds just the one commit (!).
