Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: Branch is ahead by X commits. Doesn't help doing git pull

Tags:

git

I do see other similar questions, but I dont really understand why this happens. For now, I am using git reset --hard HEAD then manually adding back my changes. The suggested solution seems to be git pull origin master? But I still get the same message after that. Whats wrong? How do I do a merge? I am still relatively new to GIT

$ git pull origin master
Nodester!
Enter passphrase for key '/home/jiewmeng/.ssh/id_rsa': 
From nodester.com:/node/git/jiewmeng/10267-f62c0a21d1a9d75ab7b6ace5858921d0
 * branch            master     -> FETCH_HEAD
Merge made by the 'recursive' strategy.

$ git branch -a
* master
  remotes/origin/master
like image 603
Jiew Meng Avatar asked Jun 10 '12 05:06

Jiew Meng


2 Answers

As mentioned in "Why is Git telling me “Your branch is ahead of 'origin/master' by 11 commits.” and how do I get it to stop?"

"your branch is ahead by..." => You need to push to the remote master.
Run "git diff origin/master" to see what the differences are between your local repository and the remote master repository.

If you're ahead of the remote repo by one commit, it's the remote repo that's out of date, not you.
Pulling wouldn't help.

Now check also if you are actually on a branch (and not on a detached head).
This is your case here (you are indeed on master branch)

like image 60
VonC Avatar answered Sep 25 '22 20:09

VonC


"Branch is ahead by X commits" can have 2 reasons: 1) You have real local commits, and you will need to do 'git push' 2) Your 'origin' branch is out of syn with remote end. Do:

git fetch

(Root cause appears to be linked to doing 'git pull origin master' instead of 'git pull')

like image 28
FractalSpace Avatar answered Sep 23 '22 20:09

FractalSpace