Folks,
This is something in git that just does not make sense to me, here is what happens
git status
, I see that I am on branch master and nothing to commit and working directory is clean.git pull origin master
I pull a bunch of code, no issues.git status
I see a new line Your branch is ahead of origin/master by 1 commit
My local repo and remote repo are totally in sync, what does your branch is ahead of origin/master by 1 commit mean, this is very very confusing.
A branch can be both ahead and behind at the same time if you have made changes to your branch, and someone else have made changes on the default branch that you have not merged into your branch yet.
It means that you have some commits in your branch that weren't pushed to origin. To keep your local branch in sync with origin, you need to push your code to that frequently.
In GitHub Desktop, click Current Branch. Click Choose a branch to merge into BRANCH. Click the branch you want to merge into the current branch, then click Merge BRANCH into BRANCH. Note: If there are merge conflicts, GitHub Desktop will warn you above the Merge BRANCH into BRANCH button.
I have experienced exactly what you see. I can't find the proper explanation on git-scm.com but I believe it to be something like this:
git pull origin master
git status
and you will see that your branch is ahead to origin/master even tough you have no new commits in your local repo and nothing to push!! (in this example, you did not commit anything new locally since step 1 (the cloning))==> I fix this by doing a git pull origin
when I'm on master.
A git pull origin master
will pull all new commits from a branch on origin to your local branch.
A git pull origin
will also re-set your reference to master equal to the commit where master is referenced on origin!! (When this didn't happen, the git-bash will just think that you are alot of commits ahead! because in the commit-tree there are alot of commits made after the commit where your master-reference is!)
Does this make any sence to you? It does to me :)
Also please feel free to support my toughts a bit with hard evidence/documentation :)
You have added a commit on your local machine, which has not yet been sent to the remote server.
If you are confident your modifications should be shared with the remote repository, sending the commit to the remote is done with the git push
command :
git push orgin master:master
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With