Video: Keep detached work and start an orphan history
The video plays in YouTube’s player, in privacy-enhanced mode.
- 5 min video
- English narration · English and Arabic captions
- Watch on YouTube
Name a commit made on a detached HEAD before you leave it, then start an orphan branch in a separate copy and see what it removes and what it keeps.
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.
- Where is HEAD? Three states.
- HEAD can name a branch, a commit, or a branch with no commit yet.
- A commit made while detached is real, but nothing names it.
- A branch on that commit keeps it reachable.
- Right-click the commit M, and choose Check Out This Commit.
- Change the stylesheet, stage it, and commit once.
- Right-click the new commit, and create a branch here, without checking it out.
- Now check out the branch. HEAD is attached again.
- With an unsaved edit, a checkout is refused. Cancel keeps everything.
- Commit first, stash and switch, or discard. Discard is the one to avoid.
- For a new history, run Create Orphan Branch from the palette.
- It counts the tracked files that leave. Untracked and ignored ones stay.
- Confirm. The folder has no tracked files.
- Add a readme, and commit. This commit has no parent.
- In the terminal, symbolic-ref exits 1 when HEAD is detached.
- On an unborn branch, rev-parse of HEAD fails.
- After the commit, merge-base finds no common ancestor.
- If you left without a branch, the reflog still has it.
- Practice: name HEAD in each state, then predict an ignored file.
- Next, recover from mistakes after pushing.