Hi! Thanks for visiting my blog. If you've received any value from my content would you mind supporting my new startup by downloading our browser add-on? It's called PriceBlink and makes online shopping a breeze. You can watch it in action here and download it for Chrome, Firefox, IE, or Safari by going to PriceBlink.com. Thank you and I hope you enjoy!

Dealing with Git: Your branch is behind ‘origin/master’ by xx commits

Jul 27

If you’re new to Git you may be working on a branch and realize that you’ve fallen out of synch with the master. In the case of Subversion you can normally do “svn up” and be good to go. In the case git you’ll normally do a “git fetch” and then a “git status” shows the following:

Your branch is behind ‘origin/master’ by 12 commits, and can be fast-forwarded.

To sync your branch with the master you can issue the following command:

git merge master

and you should now have all the latest changes from master.

6 comments

  1. You may also want to consider doing git pull –rebase… http://www.gitready.com/advanced/2009/02/11/pull-with-rebase.html has a good explanation of what it does and the difference. I like it because it avoids all the “Merged master” commits in the history.

  2. Thanks for the awesome tip! I’ve been incredibly annoyed by the “Merged master” commit but assumed there’s nothing that could be done about it. Will give this a go.

  3. actually, you’re already on master, so you probably need to do

    git merge origin/master

    (or whatever your remote is called)

  4. Rajesh Koilpillai /

    @Greg is correct, you would need to merge from origin/master.

  5. doesn’t work for me the git merge master. it will say Already up-to-date. but im still behind xx commits.

Leave a Reply