Bird
0
0

You run git tag -a v2.0 but forget to specify a commit hash. What happens?

medium📝 Debug Q6 of 15
Git - Tagging
You run git tag -a v2.0 but forget to specify a commit hash. What happens?
ATag v2.0 is created on the first commit
BError: commit hash required
CTag v2.0 is created on the current HEAD commit
DTag v2.0 is created but points to no commit
Step-by-Step Solution
Solution:
  1. Step 1: Understand default commit for tagging

    If no commit hash is given, Git tags the current HEAD commit by default.
  2. Step 2: Analyze the command behavior

    git tag -a v2.0 creates an annotated tag named v2.0 on the current commit checked out.
  3. Final Answer:

    Tag v2.0 is created on the current HEAD commit -> Option C
  4. Quick Check:

    Tag without commit = current HEAD [OK]
Quick Trick: Omit commit hash to tag current HEAD commit [OK]
Common Mistakes:
  • Expecting error if commit hash missing
  • Thinking tag points to no commit
  • Assuming tag points to first commit

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Git Quizzes