Jeff Triplett

Personal: Keeping Git Forks Updated and Tidy

From time to time, I need the ability to track upstream changes while keeping my git commit history clean, but I can never remember how. I also want to avoid messy merge commits because those are just the worst.

I’m going to assume that you have already forked a repository. I am going to use the djangocon/ repository as my example.

To track changes

$ git remote add upstream [email protected]:djangocon/

To update

Every time I want to update my local master branch:

$ git checkout master
$ git fetch upstream
$ git rebase upstream/master

To update a branch

For every branch that I want to update, I need to first check out the branch and then rebase our upstream changes to it. We will rebase against upstream/master vs. master to avoid having to rebase both master and our branch.

$ git checkout the-branch-to-update
$ git fetch upstream
$ git rebase upstream/master

Thanks to Lacey Williams Henschel for advice on and corrections to a draft of this article.