Blogmark
When to use `--force-if-includes` with `git push`
via jbranchaud@gmail.com
Every once in a while I stumble upon a wildly-thorough 2000+ word answer on StackOverflow. Most blog posts aren't this long, let alone SO answers. This is one of those answers.
So, you can try it out by using it for all
--force-with-lease
pushes. All it does is use a different algorithm—one the Git folks are hoping will be more reliable, given the way humans are—to pick the hash ID for the atomic "swap out your branch name if this matches" operation that--force-with-lease
uses. You can do this manually by providing the=<refname>:<hash>
part of--force-with-lease
, but the goal is to do it automatically, in a safer way than the current automatic way.
The tl;dr is that you probably don't need this flag, but since it is marginally safer than only the --force-with-lease
flag, you might consider using both just in case.
I guess this is why oh-my-zsh
makes it the default for gpf
for qualifying versions of git:
| gpf | On Git >= 2.30: git push --force-with-lease --force-if-includes
| gpf | On Git < 2.30: git push --force-with-lease