3

I have already seen this :-

why does it say "Your branch is ahead of origin/master by 857 commits" when I need to *pull* origin master Git - "Your branch is ahead of 'origin/master' by 3 commits." Your branch is ahead of 'origin/master' by 3 commits 'Your branch is ahead of 'origin/master' by 1 commit' on explicit push

I am new to git

but AFAICT it does not solve my issue... the thing is I get this issue often but its like it gets resolved many times by itself after a matter of time, it goes like this:-

$ git status
On branch master
Your branch is ahead of 'github/master' by 3 commits.
(use "git push" to publish your local commits)

nothing to commit, working directory clean

so I checked the github repo all changed has been already pushed...like I also pushed once again to origin/master and still git status shows this.

I also pulled from origin/master... it got successfull in pulling... but after it, it still shows the same after doing git status

Please tell me a good solution to it and also the reason if possible why this is happening... except the reason "Your local Repo is having commits which are not been pushed to remote" thank you in advance

Community
  • 1
  • 1
Shreyan Mehta
  • 551
  • 4
  • 16
  • No. Nothing happens by itself. There has to be something to it – Smit Mar 06 '17 at 15:20
  • 1
    Your branch is ahead, based on what we know since the last time we've fetched data from origin. Do `git fetch` and you'll see a different message. – aragaer Mar 06 '17 at 15:38
  • @Smit I know commit is local and push origin is remote.... – Shreyan Mehta Mar 06 '17 at 15:49
  • @aragaer yeah thanks mate it worked but can you please explain in answer section in little detail of what happened and why even after pushing and pulling It still did not got resolved – Shreyan Mehta Mar 06 '17 at 15:51

1 Answers1

3

Your branch is ahead of 'github/master' by 3 commits.

Note: your local branch is ahead of github/master not origin/master.

So, you need to push your changes to github/master. Assume you have write permission to github/master (github repo master branch).

$ git remote -v          # you can see the url of 'github' repo    

$ git push github master

Now your local and github/master should be in sync.

$ git status
Sajib Khan
  • 18,145
  • 4
  • 50
  • 65
  • In this solution we are pulling from remote and again pushing it back , so yeah this might do but I dont think this is the right solution for it anyway thanks for the efforts – Shreyan Mehta Mar 06 '17 at 15:48
  • Here, you can skip Pull, just do Push. Does it work for you? Updated answer. – Sajib Khan Mar 06 '17 at 15:51
  • Have you pushed to `github master` or `origin master` ? – Sajib Khan Mar 06 '17 at 15:54
  • I used this thing as always i push:- `git push origin master` – Shreyan Mehta Mar 06 '17 at 15:59
  • Yes, we normally push to `origin master`. But here your `git status` shows *Your branch is ahead of 'github/master' by 3 commits*. If you want to solve this you need to push your local changes to `github/master`. Here `origin` & `github` are two different repos. You can see the URLs by `git remove -v` command. – Sajib Khan Mar 06 '17 at 16:04
  • okay so it would go something like: `git push origin github/master` ?? – Shreyan Mehta Mar 06 '17 at 16:06
  • No, `github/master` denotes a remote branch (`'github' repo's 'master' branch`). e.g. `origin/master` denotes 'origin' repo's 'master' branch. So, `git push github master` should work simply! :) – Sajib Khan Mar 06 '17 at 16:12
  • uh okay but the thing is my actual remote repo is on github only so does not github/master == origin/master ?? – Shreyan Mehta Mar 06 '17 at 17:24