Closed TamaMcGlinn closed 2 years ago
Yep, that's totally cool. I still use -f
even though I'm well aware of --force-with-lease
😬 I should really probably break that habbit.
If you'd like to send a PR I'd happily merge or I can do this in the next day or so.
Thanks!
Closed by #39
Git push force-with-lease does a force push, but it sends along the current commit of 'origin/branch'. The remote receives these and does a compare and swap; we accept the new ref if the current value on the remote is still 'origin/branch' when the message arrives, so it will fail if someone else pushed in the meantime. This is really important, because your refs may not be up-to-date; this isn't a minor timing issue but a mistake that comes up regularly, where you will force push and throw away work that you were never aware of, and never will be made aware of.
That's why
git push --force
should never be used; instead, usegit push --force-with-lease
. For example, in GitExtensions the push/pull menu does not have an option for git push --force, only git push --force-with-lease.