7

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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Andrey Bushman
  • 11,712
  • 17
  • 87
  • 182
  • 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
  • Canonical: *[What is Git fast-forwarding?](https://stackoverflow.com/questions/29673869/what-is-git-fast-forwarding)* – Peter Mortensen Nov 09 '22 at 21:11

1 Answers1

5

Basically, this means that you won't be rewriting 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-1 hash value

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

git fetch
git rev-parse origin/master # Returns SHA-1 hash value

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
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Jonathan.Brink
  • 23,757
  • 20
  • 73
  • 115