1108-git tag
To add a tag in Git, you can use the following commands:
1. Create a Tag
You can create a tag at the current commit (HEAD) using:
Replace <tag_name>
with the name you want to give to the tag.
2. Tag a Specific Commit
If you want to tag a specific commit (not the current HEAD), you can do so by specifying the commit hash:
Replace <tag_name>
with the tag name and <commit_hash>
with the commit hash.
3. Add a Lightweight Tag (Simple Tag)
The above method creates a lightweight tag. It is simply a reference to a commit.
4. Create an Annotated Tag (More Detailed Tag)
To add a tag with more details (e.g., author, date, and message), you can create an annotated tag using:
The -a
flag specifies an annotated tag, and -m
allows you to add a message.
5. Push a Tag to a Remote Repository
By default, tags are not pushed to remote repositories. To push a tag, use:
To push all tags to the remote repository, use:
Let me know if you'd like more details on any of these steps!
Last updated