Quantcast
Viewing all articles
Browse latest Browse all 7

Answer by Devin Rhode for When should I use "git push --force-if-includes"

This is actually the safest possible way to force push, and my personal recommendation:

git push --force-with-lease=refs/heads/main:<expected-remote-sha> origin main

This makes --force-if-includes irrelevant, because you are telling git point blank what remote sha you expect to replace. I don't know of any way this could be made any safer.

*Of course, once you aren't specifying a full explicit sha, it becomes less safe.
**If you have new commits being pushed every second in some huge monorepo, then you're basically in a race against other developers, you probably shouldn't be force pushing.
***Credit to @torek for the *awesome* explanations!


Viewing all articles
Browse latest Browse all 7

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>