Interview Q&A / Git & GitHub

BeginnerQuick answer1 min readUpdated 3 Oct 2026

How do you tag a commit that is not the latest one?

SHORT ANSWER

Give the commit hash after the tag name, for example git tag -a v1.0 3f9c2ab -m 'Release 1.0'. Without a hash, Git tags the current HEAD.

Explain it simply

Sometimes you realise only on Monday that Friday's commit was the real release. You do not have to go back there. Hand the hash to git tag.

Find the commit with git log --oneline, then tag it directly. The tag points at that commit forever, wherever your branch is now. Verify with git show v1.0. Then push the tag as usual.

Example

bash
git log --oneline
# 9e8d7c6 Update footer
# 3f9c2ab Final fixes for launch
git tag -a v1.0 3f9c2ab -m "Release 1.0"
git push origin v1.0

What to say in the interview

"I find the commit with git log and run git tag -a name hash -m message. The tag points at that commit regardless of where HEAD is, and I push it with git push origin name."

#git#tags#commit

Related questions

Practise more Git & GitHub questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Git & GitHub quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.