Video: Reset: soft, mixed and hard
The video plays in YouTube’s player, in privacy-enhanced mode.
- 6 min video
- English narration · English and Arabic captions
- Watch on YouTube
Move a branch back one commit three ways and see what each mode does to the branch, the staging area and your files, so you pick the one that keeps the work you want.
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.
- Move a branch back, and choose how much else changes.
- Soft moves the branch. Mixed adds the index. Hard adds your files.
- So the difference is staged, unstaged, or gone.
- Build one start: a commit, a rescue branch, an unsaved edit and a note.
- Make three identical copies, and write down the ID of M.
- The edit was never committed. Keep a copy outside Git.
- The graph shows M, then C, and the rescue branch on C.
- Right-click M, open the reset submenu, and choose Soft.
- The dialog says every change stays staged, and no file changes.
- The branch is on M now. C is still on the rescue branch.
- The staged list has the old commit. The unstaged list has your edit.
- The file on disk still has your edit.
- Mixed copy: same menu, choose Mixed.
- This dialog says the changes stay, unstaged.
- Now index.html is only unstaged.
- Your edit is still in the file.
- Before hard, save the edit and the note somewhere else.
- Hard copy: choose Hard, with the dots that mean a warning.
- The dialog lists what is removed, and says it is saved first. Cancel is the default.
- Choose discard and reset.
- Only the note is left. The page is M's again.
- In the terminal, the first read is the commit. All three are M.
- git show with a colon reads the index. Soft keeps the old page.
- The status is different in each copy.
- The rescue branch is still on the older commit.
- And the file on disk: your edit twice, M's heading once.
- Change the input: no outside copy, and hard in the terminal.
- The reflog lists commits. The unsaved edit is nowhere in it.
- And hard overwrites an untracked file, if the target has one there.
- Soft and mixed lose nothing. Hard in the app is saved first.
- Practice: fill a table of branch, index and file for each mode.
- Next, undo a shared commit without rewriting history, with revert.