The reason is that it is not a fast forward push, so what we have to do to push anyway is force the push:

david@laptop$ git push desktop dev -f

In summary, if you have done some changes which result in a non-fast forward push you can push those change anyway using the ‘-f’ switch.

WARNING: Non-fast forward pushes are disabled by default to prevent you from losing changes that are on the remote repository and that are not in your local repository. If you do accidentally lose some changes on the remote end, you can log on to the remote machine, use git reflog to find the commit that was the HEAD before the forced push was executed and establish that commit as the HEAD again using git reset –hard.

Now let’s see what happens if you try to do a non-fast forward pull. First we’ll have to do some changes that will result into a non-fast forward merge. For instance, let’s squash some commits using interactive rebase:

As you can see the pull doesn’t rewrite the history, i.e. the log looks different now on the laptop and on the desktop. I find that confusing, I’d prefer having the same commit history on all my machines. Let’s undo that last pull:

What I’d like to do is something equivalent to a push –force but with a pull. The solution is using the plus sign with pull:

WARNING: The same caution as to a push –force applies, you can loose changes that are on your local repository but not on the remote repository when using a pull with the plus sign. Although, like in the previous warning, you can probably use git reflog and git reset –hard to get those changes back.

david@desktop$ git pull origin +master:master

The first master references the remote master branch and the second references the local master branch. If we now look at the commit history we can see that it is the same as on the laptop: