diff --git a/content/posts/2009-09-05-git-tag-mini-cheat-sheet-revisited.md b/content/posts/2009-09-05-git-tag-mini-cheat-sheet-revisited.md index 6eb70ec..6c0209a 100644 --- a/content/posts/2009-09-05-git-tag-mini-cheat-sheet-revisited.md +++ b/content/posts/2009-09-05-git-tag-mini-cheat-sheet-revisited.md @@ -9,73 +9,89 @@ Just as a kind of mini cheat sheet for using git tags. +``` +git tag -a -m "Tagging release 1.0" v1.0 +``` To view annotated tags you can use the same -l option as before, but you have to instruct git to show the annotation messages as well: -git tag -l -n1 +``` +git tag -l -n1 +``` This will not only show the messages for the annotated tags, it will also show the commit message of the revisions tagged with lightweight tags as well. Quite useful! -Signed tags +## Signed tags Signed tags take annotated tags a step further, they include an OpenPG signature to provide trust. While gits SHA1 tags provide integrity for the repository, the OpenPG signature makes sure that a trustworthy person created the tag. To create a signed tag you'll need to have GPG or some other OpenPG tool setup and use the -s option to sign the tag: -git tag -s -m "Tagging release 2.0" v2.0 +``` +git tag -s -m "Tagging release 2.0" v2.0 +``` The -s options implies the -a option, so here too a message is required. To verify a signed tag you can run the following: -git tag -v v2.0 +``` +git tag -v v2.0 +``` -Deleting tags +## Deleting tags There are times when you want to remove tags as well. This quite easy: -git tag -d tag_name +``` +git tag -d tag_name +``` To remove a tag on a remote repository, you should do a special push: -git push origin :refs/tags/tag_name +``` +git push origin :refs/tags/tag_name +``` -Pushing tags - -Jörg Mittag claims that annotated and signed tags are pushed and fetched automatically. I have never seen a tag of any kind being pushed automatically, so I hope Jörg can clarify this further. +## Pushing tags To push your tags to a remote repository, use the following command to push all tags: -git push origin --tags +``` +git push origin --tags +``` Happy tagging!