Why do you use `--force-with-lease`, and when does it still hurt?
IntermediateScenarioRemotes, Collaboration and Pull Requests
Answer
Situation read → After rebasing, you must overwrite the remote branch, but you want protection against deleting a teammate's new commits.
What I'd do →
git push --force-with-lease origin feature.- Pin the expected tip for more safety:
--force-with-lease=feature:<sha>; add--force-if-includes(Git 2.30+). - Avoid running
git fetchin the background (IDE auto-fetch) before pushing, because that updates the remote-tracking ref and defeats the lease check.
Why → The push only succeeds if the remote ref still equals what you last saw.
Interview tip → Plain --force never checks anything, so ban it on shared branches.
More on Remotes, Collaboration and Pull Requests
You are new to a team. How do you collaborate daily without stepping on others' toes?BeginnerYou are migrating a repo from Bitbucket to GitHub and must keep every branch and tag.IntermediateYou want to contribute a fix to an open-source project you do not have write access to.BeginnerA teammate sent a 3,000-line PR and nobody can review it properly.IntermediateA reviewer asks for changes. How do you update the PR cleanly?BeginnerYour team wants stacked PRs so that large work arrives in small reviewable steps. How do you set it up?Advanced