How to properly commit to your git repository (rebasing)
Feb 22 2010 by Andrew Brown
To be a professional Ruby on Rails developer you need to properly commit your changes to the git repos without making a big mess. Compare the two git trees below.

The problem is when your working with multiple people on a git repos you can’t work in master otherwise when you pull changes, you’ll have a messy merge and when you push you’ll make a bunch of messy lines in your git tree, and you’ll get yelled at for making those messy lines.
I want to go through the steps with you to get your git tree to look like one straight line. Look at the model below to understand what you need to do.

Lets go through the step of adding a new feature:
Make sure we’re on master
git checkout master
Make sure our master is up-to-date
git pull
Create a new branch called new_feature
git checkout -b new_feature
Make changes and commit as much as you want
git commit
1. Now we’re ready to push our changes so lets make sure our
master is up-to-date
git checkout master git pull
2. Lets rebase (If everything was up-to-date skip this step)
git checkout new_feature git rebase master
3. Merge new_feature into your master
git checkout master git merge new_feature
4. Push changes
git push
That’s all there is to it! Single clean line, nobody is yelling at you, and you can make fun of your coding friends who have never rebased before.
1 Comment to “How to properly commit to your git repository (rebasing)”