17 Oct 2011

Using git pull –rebase

One thing that I noticed myself doing with git was to to commit my changes only after stashing my changes, and performing a git pull to fetch the latest set of commits. I do this primarily to avoid the merge commits that happen when I do a git pull, after a local commit. I hate these merge commits, as they pollute the git log.

Today, I finally came across git pull --rebase, which will allow you to rebase/re-order your local commit relative to the upstream commits, and results in a much prettier git history, without all these merge commits. This way, whenever I try to push to the remote repository, and it fails because of upstream commits, I simple do a git pull --rebase, which reorders the commits nicely, so I can do a git push after that right away.

Tagged with:

Leave a Reply