Posted By: Anonymous
We are new to git, and I want to set a tag at the beginning of our repository.
Our production code is the same as the beginning repository, but we’ve made commits since then.
A tag at the beginning would allow us to “roll back” production to a known, stable state.
So how to add a tag to an arbitrary, older commit?
git tag -a v1.2 9fceb02 -m "Message here"
9fceb02 is the beginning part of the commit id.
You can then push the tag using
git push origin v1.2.
You can do
git log to show all the commit id’s in your current branch.
There is also a good chapter on tagging in the Pro Git book.
Warning: This creates tags with the current date (and that value is what will show on a GitHub releases page, for example). If you want the tag to be dated with the commit date, please look at another answer.