Role introduction
In git code management, sometimes we want to add a tag to a specific commit, such as identifying version information, at this time we can use the tagging function in git.
Putting a tag is similar to reading a book and putting a bookmark. In the future, you can directly use the tag to find the location of the submission. Otherwise, you only have to look at the hash value of the commit to return to the specified location, which is cumbersome.
With particular emphasis on:
When using Git for version control, tagging (tag) is usually used to mark a specific commit point, such as an important milestone or a version release. You can tag at any time, but usually before tagging you commit your changes and push those changes to the remote repository.
Basic operation process
Here are the basic steps of the process:
-
In your local repository, make changes to the code.
-
Commit these changes. You can use
git commit
the command to commit your changes.git commit -m "your commit message"
-
Push those commits to the remote repository. You can use
git push
the command to push your changes.git push origin your-branch-name
-
Tag a specific commit. You can use
git tag
the command to make tags.git tag -a v1.0 -m "version 1.0"
-
Push tags to a remote repository. You can use
git push --tags
the command to push your tags.git push origin --tags
For example: git push origin V1.0
Note that git tag
the default is to tag on the current commit (HEAD). If you want to tag another commit, you can git tag
append that commit's hash to the command. For example git tag -a v1.0 9fceb02 -m "version 1.0"
, where 9fceb02 is the hash of the commit you want to tag.
Some other operations:
View tags:
Through the git tag command, we can view all tags.
Delete tags:
If you want to delete a tag, you can use the git tag -d v1.0 command, where -d is the delete command and v1.0 is the name of the tag you want to delete.