sodapopcan / vim-twiggy

Git branch management for Vim
280 stars 15 forks source link

replace force with force-with-lease #38

Closed TamaMcGlinn closed 2 years ago

TamaMcGlinn commented 3 years ago

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, use git 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.

sodapopcan commented 3 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!

sodapopcan commented 2 years ago

Closed by #39