Interview Prep/Git & GitHub/Undoing changes: reset, revert, restore and reflog

What is the difference between `--force` and `--force-with-lease`?

IntermediateConceptUndoing changes: reset, revert, restore and reflog
Answer

--force overwrites the remote ref regardless. --force-with-lease only overwrites if the remote ref still equals what you last fetched (or an explicit expected SHA), so you do not clobber a colleague's push you have not seen. Add --force-if-includes to guard against a background fetch that updated your tracking ref.

git push --force-with-lease --force-if-includes origin feature/x
All Git & GitHub questions Roadmap: Git & GitHub

More on Undoing changes: reset, revert, restore and reflog