gitgit-pull

Is there another layer of verbosity I can access after a failed git pull?


Right after successfully pushing all changes on my feature branch to the remote, I try the following on my feature branch and get the following output:

git pull origin master
From git.mycompany.com:core/main
 * branch                    master     -> FETCH_HEAD
fatal: Not possible to fast-forward, aborting.

Sure. Fine. Maybe I can get more information with the --verbose flag.

git pull --ff-only --verbose origin master
From git.mycompany.com:core/main
 * branch                    master     -> FETCH_HEAD
 = [up to date]              master     -> origin/master
fatal: Not possible to fast-forward, aborting.

Okay, that doesn't give me much more. This "verbose" message still seems extremely vague. Which leads to my question.

Is there another layer of verbosity I can access when trying to fast forward, in order to debug and fix the problem? If so, how?


Solution

  • With git pull, this is all the verbosity you can get. A fast-foward merge was requested, e.g., by a configuration setting like pull.ff=only, but a fast-forward merge was not possible.

    The next step is to know the relationship between the current HEAD and the branch tip that is being merged, i.e., to get to know the commit graph and commit history.

    For a merge, the commit graph can be discovered with this git log command:

    git log --graph --oneline --decorate --boundary HEAD...origin/master
    

    The result may look like this when the histories have diverged:

    * c129ba6 (HEAD -> master) more change
    * 1f6b196 example commit
    * 6cd8049 example fix
    | * 2f51d91 (origin/master) example fix
    |/  
    o e244588 start
    

    Of note are:

    If history is complex it may be helpful to also throw in --left-right. The output marks up from which side the commits are reachable and looks like this:

    < c129ba6 (HEAD -> master) more change
    < 1f6b196 example commit
    < 6cd8049 example fix
    | > 2f51d91 (origin/master) example fix
    |/  
    o e244588 start
    

    < commits are reachable from HEAD, > commits are reachable from origin/master. (It's not very useful in this simple example.)