Git: Your branch is ahead of the tracked remote branch

From FVue
Jump to: navigation, search


When moving to a local branch, git says I'm "ahead of the tracked remote branch", but a git push doesn't update the remote branch.

$ git checkout mybranch
Your branch is ahead of the tracked remote branch 'origin/remotebranch' by 1 commit.
$ git push
Everything up-to-date

Solution 1. Pushing mybranch to remotebranch

$ git push origin mybranch:remotebranch

or for later pushes with just git push origin you can put this in .git/config with this command:

$ git config remote.origin.push mybranch:remotebranch

Solution 2. Reset mybranch to state of remotebranch

NOTE: Careful! You will loose commits made to mybranch!

$ git reset --hard origin/remotebranch

See also

Nabble - git - Local branch ahead of tracked remote branch but git push claims everything up-to-date
Same question in forum with clear explanation from "Michael J Gruber" at the end

Useful commands are:

git ls-remote origin
git ls-remote .
git log --pretty=oneline mybranch...origin/remotebranch


blog comments powered by Disqus