This is the fourth day of my participation in the August More text Challenge. For details, see: August More Text Challenge

What is a tag

  • A Git repository tag is a git repository tag that points to a snapshot of a commit ID tag, so the tag is also a snapshot of the repository.

  • The tag is used to manage the release version. When the release is released, the current Git HEAD (commit ID) can be tagged with v.1.0.1, V.1.0.2, etc.

  • Tag feels a bit like Branch, but is different in nature and division of labor.

The characteristics of the tag

  • The tag corresponds to a commit node. It is a point and cannot be moved.

  • A branch is a series of commit points, a line with a HEAD pointer, and can be moved by the HEAD pointer.

  • So, the difference between the two determines how to use it: branch if you change the code, tag if you don’t change the code.

The use of Tag and Branch together can sometimes be very convenient. For example, when I released v1.0, V2.0, and V3.0, I suddenly wanted to add a new feature to v2.0 and release it as V4.0 without changing the existing code. You can check out the V2.0 code as a branch and then as a development branch.

Create a label

Add the tag

git tag -a -m “added description release notes” #

Git tag = git tag = git tag

The processing command is:
Git Tag-a v1.0-beta-mCopy the code

Create a lightweight label without using -a, -m, and other parameters

For example,
Git tag v1.0Copy the code

Tag the specified COMMIT

You don’t need to use the Tag on top of the head. You can also use the Tag in previous versions, which requires you to know the checksum of a commit object (obtained from the Git log).

Git tag -a v0.1.1 9fbc3D0Copy the code

You can add -m to add comments

View all tag versions

  • Git tag: View the tag list
  • Git tag –list: See the list of tags
  • Git tag -l: Check the tag list for the same reason

The git checkout [tagname] command is used to switch the tag.

Git checkout v1.0Copy the code

Remove the tag

git tag -d tagName
Copy the code
Example Delete the local Tag v1.0
Git tag - d v1.0Copy the code

Git push Origin :refs/tags/ #

You can only see your new Tag locally, but you can’t see what’s under the Tags in the remote central repository, because we haven’t pushed it to the central repository yet, okay

Push to the remote end

Git push Origin #

Such as:

Git push origin v1.0Copy the code
Push all unpushed local labels
git push origin --tags 
Copy the code

If it is not synchronized with the remote, you can pull it down first

git pull --rebase origin master
Copy the code

Upload again

git push -u origin master
Copy the code
Push all tags
git push origin --tags
Copy the code

History commits are tagged here

  • git log –pretty=oneline –abbrev-commit
15027957951b64cf874c3557a0f3547bd83b3ff6 Merge branch 'experiment'
a6b4c97498bd301d84096da251c98a07c7723e65 beginning write support
0d52aaab4479697da7686c15f77a3d64d9165190 one more thing
6d52a271eda8725415634dd79daabbc4d9b6008e Merge branch 'experiment'
0b7434d86859cc7b8c3d5e1dddfed66ff742fcbc added a commit function
4682c3261057305bdd616e23b64b0857d832627b added a todo file
166ae0c4d3f420721acbb115cc33848dfcc2121a started write support
9fceb02d0ae598e95dc970b74767f19372d61af8 updated rakefile
964f16d36dfccde844893cac5b347e7b3d44abbc commit the todo
8a5cbc430f1a9c3d00faaeffd07798508422908a updated readme
Copy the code

Now, let’s say you forgot to tag the project in V1.2 and submit it on an “updated Rakefile”. You can fill in the tags later. To tag that submission, you need to specify the checksum (or partial checksum) for the submission at the end of the command:


  • Git tag -a v0.9 -m “V0.9 is available

(Summary) Push local tags to the remote repository

  • Git push Origin v1.0-beta #
  • Git push Origin v1.0-beta:refs/tags/v1.0-beta
  • Git Push Origin –tags # push all local tags that have not been pushed to remote

Deleting a Remote Tag

  • git tag -d tag-name
  • git push origin :refs/tags/tag-name

Overwrite the original tag

  • git tag -f lilerong

View the version information about the corresponding label

Git show tagName //git show command, together with the display of the commit object when tagged

Create tag tag in IDEA and push to remote warehouse

Create a tag

After the creation, push the label to the remote repository

And then you type in the tag name (usually it’s a regular thing not a random thing)

Because the tags are not typed in the latest version, you need to select push tags (all) when pushing, otherwise you cannot push.

You can see the label you just pushed in the GitLab TAB