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
More on Undoing changes: reset, revert, restore and reflog
What are the three modes of `git reset`?BeginnerWhat is the difference between `git reset` and `git revert`?BeginnerHow do you discard changes in one file?BeginnerHow do you recover a commit after `git reset --hard`?IntermediateCan you recover uncommitted changes lost by `git reset --hard` or `git checkout .`?IntermediateWhat does `git commit --amend` do to the reflog and to the old commit?Intermediate