How to make `git push -f`" safe "

Is there a way to use git push -fbut just origin/masternot changed since the last click?

I only want to reorganize the history, and not overwrite the contents of the file.

+4
source share
1 answer

There is an option --force-with-leasefor git push . Performance

git push --force-with-lease

will do exactly what you want and only force update the remote branch if it is still on the same version as your remote tracking branch (i.e. origin/branch).

You can also specify a revision explicitly if you want to check a different version:

git push --force-with-lease=branch:someCommitHash
+7
source

Source: https://habr.com/ru/post/1546382/


All Articles