Warm-up · from “Upstream branches and refspecs”
What does the colon separate?
What does the colon separate?
No notes: write what you remember, then check. Recalling before reading is what makes it stick.
The problem
You rewrote a private feature branch while a teammate added a commit. A blind force-push could overwrite their work.
After this lesson you can
Recognize non-fast-forward rejection.
Explain force-with-lease limits.
Choose safe collaboration steps.
Key terms
Full glossarySay what each term means, then open it to check.
Remote-tracking ref · from lesson 22
Local record of a remote branch state, updated by configured operations.
Commit · from lesson 7
Object identifying a root tree, parent(s), metadata and message.
Ref · from lesson 3
Name identifying an object; branch refs usually identify commits.
Visual mental model
- Remote tip
- Recorded expected ID
- Lease compares
- Accept or reject
Build the mental model
A normal push to a branch is fast-forward when the old remote tip is an ancestor of the new tip. If it is not, Git generally refuses. Prefer integrating others' work or pushing a new branch rather than rewriting shared history. Branch protection and server hooks may impose additional restrictions. A deliberate rewrite of an agreed private branch can use a lease to check the remote ref's expected value.
A simplified model for building intuition. It does not read your sandbox; use the terminal for real behaviour.
Under the hood
Without an explicit expected ID, --force-with-lease commonly compares the server ref with the local remote-tracking ref. Background fetches may update that ref to a commit you never reviewed, weakening the protection. For deliberate rewrites, first fetch and inspect the exact remote tip, record it, agree with collaborators, and use --force-with-lease=refs/heads/NAME:EXPECTED. A lease is not a substitute for reviewing changes or respecting policy.
Common mistake · important nuance
This lab pushes only to a local bare repository. Never experiment with forced pushes on a real shared branch.