What is a fast-forwarding push in Git?


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?


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

Answered By – Jonathan.Brink

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published