faboolous faboolous - 3 years ago 497
Git Question

git: "Updates were rejected because the tip of your current branch is behind.." but how to see differences?

I just finished working on a piece of code. Wanted to push and got the already famous:


hint: Updates were rejected because the tip of your current branch is
behind hint: its remote counterpart. Integrate the remote changes
(e.g. hint: 'git pull ...') before pushing again.


Now I've seen this question posted several times here, e.g.

Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g

Updates were rejected because the tip of your current branch is behind

According to the specific case, the solution is either to


  • git pull
    , so the remote changes are merged on to my local work, OR

  • git push -f
    , a force push to update the remote (origin) branch.



Now, it has been a while I haven't worked on this branch. I don't necessarily want to merge the remote changes onto my current work! Nor do I know if I can safely force the update on the origin branch...

How can I just see the differences and decide which is best for my case?

Ben Ben
Answer Source

in order to see the differences, first you need to fetch the commits from the origin repository:

git fetch origin

Now you can see the diffs (Assuming you are on the master branch) git diff HEAD..origin/master

Now you are armed with the knowledge you seek to decide to merge or rebase before pushing your changes.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download