Skip to content
GitTree

Video: Recover mistakes after pushing

The video plays in YouTube’s player, in privacy-enhanced mode.

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.

Go to the lesson

Video transcript

The narration of the video, cue by cue.

  1. You pushed a mistake. What now?
  2. If others may have the commit, repair it by adding a commit.
  3. A lease says: replace the remote only if it is still where I expect.
  4. But a fetch moves what a bare lease expects.
  5. Two branches on a local server: shared, and lease.
  6. On shared, revert the bad commit.
  7. Push normally. No force.
  8. The mistake stays in history, and nobody must repair a clone.
  9. On lease, a rewritten branch is refused.
  10. Fetch only, and look. Leo's commit is there.
  11. It proceeds only while the remote is at this commit, and keeps the old tip.
  12. Leo's work is not yours to replace. Rebase onto it, or ask him.
  13. In the terminal, the ancestor check on shared is zero.
  14. Name the commit you reviewed. Git says stale info.
  15. The server still names Leo's commit.
  16. A bare lease after a fetch would have replaced it.
  17. Undo does not reverse a force push on a server.
  18. Practice: report the exit code, the server commit, and the status.
  19. Next, work on two branches at once with worktrees.

All tutorials