2

I am trying to git push origin master and getting the error ! [rejected] master -> master (non-fast-forward). I understand what the error means. (1)

However, I want to decide whether or not to --force the update anyway. To do this I need to see and compare the commits my local branch and the target remote branch. How can I see them side by side? I would prefer to use a GUI tool like gitg, but a readable command-line option will suffice.


(1) It means that my local branch is not a direct descendant of the target remote branch. This is explained in:

2
  • Did you ran git pull first? IMO that would prevent headaches.
    – Braiam
    Nov 8, 2013 at 13:26
  • @Braiam yes I did, but your question prompted me to do another search and I found stackoverflow.com/questions/4312059/… includes several tools for the job - thanks!
    – lofidevops
    Dec 2, 2013 at 9:32

1 Answer 1

1

You can use the following tools to visualize and compare the repos:

git log --graph

You can use the git command line:

git log --graph --oneline --all --decorate

From the man page: "Draw a text-based graphical representation of the commit history on the left hand side of the output. This may cause extra lines to be printed in between commits, in order for the graph history to be drawn properly."

See Viewing the Commit History for an example (you'll have to scroll down quite a bit).

gitk

You can use the gitk GUI:

git fetch origin # make sure you are up-to-date
gitk branchname origin/branchname # launch gitk

Using this command you can see how the local and remote branch have diverged.

Other tools

Other GUI tools may have similar visualization options. See rob mayoff's answer to "What does it mean that a Git push can not be fast foward merged?" for an example of what you might see.

Non-fast-forward

All these tools were mentioned while investigating why git pull says up-to-date but git push rejects non-fast forward on StackOverflow. Answers include tips on resolving the non-fast-forward without forcing. (A common reason is having a local branch with the same name as a remote one - for example, having both a local and remote branch named origin/new-feature instead of having the local branch named just new-feature.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .