Is there a way to use git push -f
, but only origin/master
hasn't changed since the last pull?
I only want to reorganize history, not overwrite file contents.
There is an option called --force-with-lease
for git push. Doing
git push --force-with-lease
will do exactly what you desire 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 explicitely if you want to check for another version:
git push --force-with-lease=branch:someCommitHash
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With