In my previous post last month I described the migration from SVN to Git. Since then I have been using it in my project. This post is about the typical workflow and how it can be achieved in Git.
1. Getting code
git pull <repo URL>
This will pull the remote repository on your machine. The URL can be HTTP/HTTPS or SSH. In case of SSH you will need to generate a key pair first.
2. Seeing what has changed
Shows the current branch you are on and the staged and unstaged changes.
3. Committing Changes
git commit -a -m <commit message>
Commits all the staged changes.
4. Pushing commits
Push all commits to the remote repository
5. Storing current changes and going back to HEAD
git stash save <stash name>
All current changes are stashed away in a temporary area and resets the current branch
6. Restoring previously stored changes
git stash apply <stash name>
Merges the stashed changes back into the working copy
7. Create a new branch
git branch <branch name>
8. Switch to another branch
git checkout <branch name>
9. Merge branch with master
git checkout master
git merge <branch to merge>
10. Cherry pick changes from another branch
git cherry-pick -e -x <commit>
Pick specific commits, maybe from another branch, and apply to working copy
git tag <tag name>
If you are new to Git you will find the Git GUI to be very handy. However, it does not support all the git commands such as stash. I always end up using both the command line and GUI at times when I get a bit lazy.