Detailed explanation of git tag

In Git, Tag is a pointer used to mark a specific commit (commit), which is a static reference with a descriptive name. The following is a detailed explanation of Git Tag:

  1. Create tags:

    • git tagA Tag can be created using  the command. For example, git tag v1.0.0a Tag named v1.0.0 will be created.
    • Tag can point directly to a commit, or it can point to a specific branch.
  2. Label type:

    • Git has two types of Tags: Lightweight Tags and Annotated Tags.
    • A lightweight tag is just a reference to a specific commit, with no additional information.
    • An annotated tag is a self-contained Git object that contains additional information about the tag's author, date, comments, etc.
  3. View Tags:

    • Use  git tagthe command to list all tags.
    • Use  git show <tagname>to view the detailed information of a specific Tag.
    • Use  git tag -l 'pattern'to find matching Tags by pattern.
  4. Switch to Tag:

    • Use  git checkout <tagname>to switch the working directory to a specific Tag.
    • Note that switching to Tag will put you in a "detached head pointer" state, meaning you will no longer be on any branch and your changes will not be saved.
  5. Push and delete Tag:

    • Use  git push origin <tagname>the command to push the specified Tag to the remote warehouse.
    • Use  git push origin --tagsthe command to push all local tags to the remote warehouse.
    • Use  git tag -d <tagname>commands to delete local tags.
    • Use  git push origin :refs/tags/<tagname>the command to delete the Tag on the remote warehouse.

By using Git's Tag function, we can mark important milestones, version releases or specific commits in the code base. Tag allows us to easily backtrack, view and manage the historical state of the code base. Hope this information helps you!

Guess you like

Origin blog.csdn.net/tiansyun/article/details/132114834