6

From the Git documentation:

By default, the configuration flag receive.denyNonFastForwards is enabled in shared repositories, so that you cannot force a non fast-forwarding push into it.

I know about the git push command, but what is fast-forwarding push?

Andrey Bushman
  • 10,992
  • 14
  • 77
  • 163
  • http://ariya.ofilabs.com/2013/09/fast-forward-git-merge.html – Tobia Tesan Sep 10 '15 at 12:45
  • 3
    possible duplicate of [What does "Git push non-fast-forward updates were rejected" mean?](http://stackoverflow.com/questions/4684352/what-does-git-push-non-fast-forward-updates-were-rejected-mean) – IMSoP Sep 10 '15 at 12:47
  • Does this answer your question? [What is the difference between \`git merge\` and \`git merge --no-ff\`?](https://stackoverflow.com/questions/9069061/what-is-the-difference-between-git-merge-and-git-merge-no-ff) – Henke Dec 27 '20 at 15:13

1 Answers1

5

Basically this means that you won't be re-writing commit history that already exists on your Git server (the already-pushed stuff).

If this history changes it could be a problem for others who have already pulled and worked off that history.

A manual way to determine if you are pushing "fast forward" is to look at what ref you have for your downloaded copy of your branches remote (let's say master):

git rev-parse origin/master #returns sha

Then, download the content from your remote server and check again:

git fetch
git rev-parse origin/master #returns sha

If the return result of those those two rev-parse commands are equal your push will be fast-forward.

BUT...all that work really isn't necessary. Just simply pull before you push and you will be good.

git pull origin master
# resolve any conflicts
git push origin master
Jonathan.Brink
  • 21,521
  • 16
  • 66
  • 107