Last active
November 11, 2023 05:16
-
-
Save tadd/c504b2f5c8f07dd717726c049e0e55f1 to your computer and use it in GitHub Desktop.
Force not to use `git push -f` but `--force-with-lease`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -eu | |
argv="$(sed -E 's/(^| )-f\b/\1--force-with-lease/g' <<<$@)" | |
exec git push ${argv} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pro Tips™
git
builtins. Use something like this to cope with it.-f
but not--force
; This method is provided by design as an explicit loophole.git config --global push.useForceIfIncludes true
for your safety1.push.useForceIfIncludes true
/--force-if-includes
does nothing without--force-with-lease
. (It's just an ancillary option)Acknowledgments
This gist is inspired by @onk's blog entry. Thanks a lot!
Footnotes
Your safety is not that much of my priority, though ↩