Changing history

Undoing changes with restore, reset, revert and the reflog; rebasing; and stashes, tags and semantic versions.

About 4 hours of study

Learning objectives

Lessons

  1. 1

    Undoing changes: restore, reset, revert and the reflog Intermediate

    Fix mistakes at every stage: discard edits with git restore, unstage files, move a branch back with git reset in its three modes, undo a shared commit safely with git revert, amend the last commit, and recover "lost" commits from the reflog.

  2. 2

    Rebasing Advanced

    Move a branch's commits onto a new base to keep history linear. See which commits a rebase replays, rewrite commits with an interactive rebase (reword, squash, fixup, drop), handle conflicts commit by commit, and follow the golden rule of rebasing.

  3. 3

    Stashing work and tagging releases Intermediate

    Put unfinished work aside with git stash while you fix something urgent, and mark releases with tags. Use semantic versioning to name versions, compare them correctly, and describe any commit relative to the latest tag.

Module practice

Module quiz

1. Which reset mode keeps changes staged?
2. What does git stash pop do?
3. How do you undo a commit that others have pulled?
4. What happens to commit ids during a rebase?
5. Which version is newer: 1.9.3 or 1.10.0?
6. After a mistaken git reset --hard, where do you find the lost commit?

‹ Branching and mergingCollaboration ›