Chapter 3: Version control

Force push

Also called git push --force, --force-with-lease

Telling the server to replace a branch with yours, even when that throws away commits it has. A normal push can only add. This one can delete other people's work from the server, and it barely mentions it.

This is the git command whose damage lands on other people. An agent reaches for it when a normal push is refused, and a refused push often means someone else's work is in the way. On your own branch after a rebase it is routine. On a shared one, it needs a person.

Say it to your agent

“If a push is refused, stop and tell me why. Don't use --force, -f or a + refspec. If this is your own branch and you rebased it, use git push --force-with-lease --force-if-includes on that branch only, and never on main.”

The workshop

Name a word, or describe what you mean in everyday language.