35

I have a commit with 1 ahead and 6 behind.

What should I do in this situation?

I think, that solution might be like this: git push and after git pull

But I think, it can solve only Behind.
Maybe I am wrong.

-------*------*-----*-----*-----B
        \
         \
          \
           *-------A

I make my part and change sdk.
Now I want to merge with B.

gaussblurinc
  • 3,642
  • 9
  • 35
  • 64

1 Answers1

37

git pull (or rather, the git merge part that pull does) will "solve" both 'ahead' and 'behind'.

branch is X commits behind means that there are X new (unmerged) commits on the branch which is being tracked by your current branch.

branch is X commits ahead analogously means that your branch has X new commits, which haven't been merged into the tracked branch yet.

Once you've pulled (thereby merging the remote changes into your local ones) and pushed (thereby publishing your changes and the merge to the remote), your own branch and the remote branch will point to the same commit, so neither is ahead or behind.

Nevik Rehnel
  • 49,633
  • 6
  • 60
  • 50
  • 6
    `git pull` did indeed resovle the "behind" problem, then I executed `git push` which cleared the "ahead". – Ville Dec 19 '13 at 22:20