Skip to content

Instantly share code, notes, and snippets.

@davidchua
Created April 7, 2010 11:42
Show Gist options
  • Save davidchua/358782 to your computer and use it in GitHub Desktop.
Save davidchua/358782 to your computer and use it in GitHub Desktop.
Workflow:
1) Do a git pull to ensure your master is having the latest copy
2) Create a new branch with the command
git checkout -b <branchname>
"I'd normally name the branchname something in relation to the task at hand, this is supposed to make your life easier."
3) Make sure you're now in that branch, if not do a
git checkout <branchname>
4) Do your magic! (writing code of course)
5) Commit. (still in your branch)
Now between the time you branched out and the time your did your commit, someone else could had made an update to the codebase in the remote repository. Normally, what you guys are doing is to do a git pull just before you push. What this does is to put your code underneath everyone else's code, and increasing the chances of conflicts.
What you should do instead is:
6) Switch back to your master branch (git checkout master)
7) Do a git pull to the latest HEAD
8) Switch back to your <branch> branch
9) Do a git rebase master (What this does is to put your changes ontop of your master branch)
10) Switch back to master
11) Do a git merge <branch> (Puts your committed codebase back into your master)
12) Git push!
Wahla!
Do a git log and you should see your code beautifully placed at the top of your repository. Without the merge commits.
Hope this helps :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment