You will use Git Tags all the time now! 😄

Git has the ability to tag specific points in a repository’s history. This is useful to mark releases (like v1.2 or v2.0).

What you will learn?

Types of git tags and how to create them?
List existing git tags.
How to delete a git tag?
How to move th…


This content originally appeared on DEV Community and was authored by Alish Giri

Git has the ability to tag specific points in a repository’s history. This is useful to mark releases (like v1.2 or v2.0).

What you will learn?

  • Types of git tags and how to create them?
  • List existing git tags.
  • How to delete a git tag?
  • How to move the last tag to the latest commit?
  • How to edit a tag message?
  • How to get the code from a specific tag?

Types of git tags and how to create them?

There are two types of git tags: lightweight and annotated.

Most of the time you will use Annotated tags. A Lightweight tag is mostly used for private purposes.

Annotated Tags

This stores information such as tagger name, email, and date; have a tagging message; and can be signed and verified with GNU Privacy Guard (GPG).

git tag -a v1.9 -m "your release information..." -s
# -a = annotated
# -m = message
# -s = signed

# Use this to list detailed information that the tag stores.
git show v1.9

Lightweight Tags

Do not use -a, -s, or -m to apply lightweight tag, just provide a tag name.

git tag v1.9

# Use this to list detailed information that the tag stores.
git show v1.9

List existing git tags.

git tag

This command lists tag in alphabetical order.

# Output
v1.0
v1.1
v1.2

You can also search for tags that match a particular pattern.

git tag -l "v1.8*"
# Output
v1.8
v1.8-rc0
v1.8-rc1
v1.8-rc2
v1.8-rc3

How to delete a git tag?

git tag -d v1.8
# -d = delete

How to move the last tag to the latest commit?

git tag -f -a <tag_name>

git push -f --tags

How to edit a tag message?

git tag -m '<edited_message>' --edit <tag_name> -s -f

How to get the code from a specific tag?

You can checkout a tag and create a new branch from it.

git checkout -b [new_branch_name] [tag_name]


This content originally appeared on DEV Community and was authored by Alish Giri


Print Share Comment Cite Upload Translate Updates
APA

Alish Giri | Sciencx (2024-10-19T12:18:19+00:00) You will use Git Tags all the time now! 😄. Retrieved from https://www.scien.cx/2024/10/19/you-will-use-git-tags-all-the-time-now-%f0%9f%98%84/

MLA
" » You will use Git Tags all the time now! 😄." Alish Giri | Sciencx - Saturday October 19, 2024, https://www.scien.cx/2024/10/19/you-will-use-git-tags-all-the-time-now-%f0%9f%98%84/
HARVARD
Alish Giri | Sciencx Saturday October 19, 2024 » You will use Git Tags all the time now! 😄., viewed ,<https://www.scien.cx/2024/10/19/you-will-use-git-tags-all-the-time-now-%f0%9f%98%84/>
VANCOUVER
Alish Giri | Sciencx - » You will use Git Tags all the time now! 😄. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/10/19/you-will-use-git-tags-all-the-time-now-%f0%9f%98%84/
CHICAGO
" » You will use Git Tags all the time now! 😄." Alish Giri | Sciencx - Accessed . https://www.scien.cx/2024/10/19/you-will-use-git-tags-all-the-time-now-%f0%9f%98%84/
IEEE
" » You will use Git Tags all the time now! 😄." Alish Giri | Sciencx [Online]. Available: https://www.scien.cx/2024/10/19/you-will-use-git-tags-all-the-time-now-%f0%9f%98%84/. [Accessed: ]
rf:citation
» You will use Git Tags all the time now! 😄 | Alish Giri | Sciencx | https://www.scien.cx/2024/10/19/you-will-use-git-tags-all-the-time-now-%f0%9f%98%84/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.