QuestenaPractice that shows what to review next
Question 6

You run `git checkout 4f2a9c1` (a raw commit hash) and then create a new commit. What is true about your situation?

  1. Git automatically created a temporary branch to hold your new commit
  2. The new commit was recorded onto the branch that had been checked out before you ran the checkout
  3. HEAD is detached; the commit is on no branch and may be lost unless a branch or tag points to itCorrect answer
  4. Git refuses to create commits while a raw commit hash is checked out

Explanation

Checking out a commit hash rather than a branch name detaches HEAD: HEAD points directly at the commit instead of at a branch. Committing in this state works fine, but the new commit belongs to no branch, so once you switch elsewhere nothing references it and it eventually becomes eligible for garbage collection. Creating a branch or tag at that commit before (or shortly after, via the reflog) switching away preserves it. Git creates no temporary branch and does not refuse to commit.

Continue with this test

Start practice
Question 6: You run `git checkout 4f2a9c1` (a raw commit hash) and then… · Git Fundamentals · Questena