Skip to content
GitTree

Video: Keep detached work and start an orphan history

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

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.

Go to the lesson

Video transcript

The narration of the video, cue by cue.

  1. Where is HEAD? Three states.
  2. HEAD can name a branch, a commit, or a branch with no commit yet.
  3. A commit made while detached is real, but nothing names it.
  4. A branch on that commit keeps it reachable.
  5. Right-click the commit M, and choose Check Out This Commit.
  6. Change the stylesheet, stage it, and commit once.
  7. Right-click the new commit, and create a branch here, without checking it out.
  8. Now check out the branch. HEAD is attached again.
  9. With an unsaved edit, a checkout is refused. Cancel keeps everything.
  10. Commit first, stash and switch, or discard. Discard is the one to avoid.
  11. For a new history, run Create Orphan Branch from the palette.
  12. It counts the tracked files that leave. Untracked and ignored ones stay.
  13. Confirm. The folder has no tracked files.
  14. Add a readme, and commit. This commit has no parent.
  15. In the terminal, symbolic-ref exits 1 when HEAD is detached.
  16. On an unborn branch, rev-parse of HEAD fails.
  17. After the commit, merge-base finds no common ancestor.
  18. If you left without a branch, the reflog still has it.
  19. Practice: name HEAD in each state, then predict an ignored file.
  20. Next, recover from mistakes after pushing.

All tutorials