I recently heard about git --force-with-lease and why it is (in many cases) superior to the regular git --force.

Atlassian dev blog has a nice article with a worked-out example.

TL;DR. If one has chosen to use feature branches in git, often one also wants them beautifully based on the up-to-date master branch before merging them. So one would do a git rebase master and then git push --force the rebased feature branch back to origin.

But if there’s multiple collaborators working on the same repository, one can easily end up destroying other people’s work (or worse) by blindly applying --force to git push. Fortunately, there is a solution called --force-with-lease. Details in the blog post.

So in other words, this way one can safely work with nice and tidy rebased feature branches (without ugly merges in commit log) on a collaborative project managed with Git. Always wondered how that was supposed to be done; Thus far I’ve been wary of using --force, applying it only when working on my own private repos where I can be absolutely sure of their internal state.