Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between git push --force vs git push non fast forward update

Tags:

git

Let us say I run

git push --force origin master:master (forced update)

and at another place

git push origin +master:master (Non fast forward update)

Are these 2 same ? Any scenario where these 2 behave differently ?

like image 659
Number945 Avatar asked May 06 '26 11:05

Number945


1 Answers

They are identical. From the docs:

All of the rules described above about what’s not allowed as an update can be overridden by adding an the optional leading + to a refspec (or using --force command line option).

However, and perhaps obviously, --force applies to everything that's being pushed, whereas + applies to only that refspec prefixed with the + (master in this case). In the two commands in your question, that doesn't make a difference because there is only one refspec in both of them.

like image 196
Thomas Avatar answered May 08 '26 02:05

Thomas