Video: Recover mistakes after pushing
The video plays in YouTube’s player, in privacy-enhanced mode.
- 4 min video
- English narration · English and Arabic captions
- Watch on YouTube
Repair a mistake that others may already have: prefer a new commit, and when you must rewrite a branch you own, force with a lease pinned to the exact remote tip you reviewed.
Read the full lesson
The article has every step and command from the video, the practice exercise and the questions.
Video transcript
The narration of the video, cue by cue.
- You pushed a mistake. What now?
- If others may have the commit, repair it by adding a commit.
- A lease says: replace the remote only if it is still where I expect.
- But a fetch moves what a bare lease expects.
- Two branches on a local server: shared, and lease.
- On shared, revert the bad commit.
- Push normally. No force.
- The mistake stays in history, and nobody must repair a clone.
- On lease, a rewritten branch is refused.
- Fetch only, and look. Leo's commit is there.
- It proceeds only while the remote is at this commit, and keeps the old tip.
- Leo's work is not yours to replace. Rebase onto it, or ask him.
- In the terminal, the ancestor check on shared is zero.
- Name the commit you reviewed. Git says stale info.
- The server still names Leo's commit.
- A bare lease after a fetch would have replaced it.
- Undo does not reverse a force push on a server.
- Practice: report the exit code, the server commit, and the status.
- Next, work on two branches at once with worktrees.