Bird
0
0

You want to create a tag named staging on the commit that is three commits before the current HEAD. Which command should you use?

hard📝 Best Practice Q8 of 15
Git - Tagging
You want to create a tag named staging on the commit that is three commits before the current HEAD. Which command should you use?
Agit tag staging HEAD^^^
Bgit tag staging HEAD^3
Cgit tag staging HEAD~1~2
Dgit tag staging HEAD~3
Step-by-Step Solution
Solution:
  1. Step 1: Understand commit references

    HEAD~3 means three commits before HEAD.
  2. Step 2: Evaluate options

    HEAD^3 means the third parent of a merge commit, not three commits before.
    HEAD~1~2 is equivalent to HEAD~3 but less clear.
    HEAD^^^ also means three commits before HEAD but is less readable.
  3. Step 3: Best practice

    Using HEAD~3 is the clearest and most common way.
  4. Final Answer:

    git tag staging HEAD~3 -> Option D
  5. Quick Check:

    Use HEAD~N for N commits before HEAD [OK]
Quick Trick: HEAD~N is best for N commits before HEAD [OK]
Common Mistakes:
  • Confusing ^ and ~ notation
  • Using merge parent notation incorrectly
  • Overcomplicating commit references

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Git Quizzes