What is the difference between git push --force and --force-with-lease?
--force overwrites the remote branch no matter what. --force-with-lease overwrites only if the remote is still where you last saw it, so you do not wipe out commits a teammate pushed meanwhile.
Explain it simply
Imagine replacing a shared notice with a new one. --force tears down whatever is hanging there. --force-with-lease first checks the notice is the same one you saw when you last looked; if someone changed it, you stop.
Git compares the remote branch with your remote-tracking ref (origin/feature). If they match, the push goes through. If a teammate pushed after your last fetch, it fails and you can fetch and review. It is the sensible default after an amend or rebase on your own pushed branch. It is not perfect, because an automatic background fetch can update your reference and fool the check.
Example
git rebase main
git push --force-with-lease origin feature/search
# ! [rejected] (stale info) -> someone pushed; fetch and reviewWhat to say in the interview
"--force overwrites the remote unconditionally, while --force-with-lease fails if the remote has commits I have not seen. After rebasing my own branch I use --force-with-lease so I never silently delete a teammate's work."