Git basic operations: the role of version tagging and the basic operation process

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:

  1. In your local repository, make changes to the code.

  2. Commit these changes. You can use git committhe command to commit your changes.

    git commit -m "your commit message"
    
  3. Push those commits to the remote repository. You can use git pushthe command to push your changes.

    git push origin your-branch-name
    
  4. Tag a specific commit. You can use git tagthe command to make tags.

    git tag -a v1.0 -m "version 1.0"
    
  5. Push tags to a remote repository. You can use git push --tagsthe command to push your tags.

    git push origin --tags
    

    For example: git push origin V1.0

Note that git tagthe default is to tag on the current commit (HEAD). If you want to tag another commit, you can git tagappend 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.
insert image description here

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.

Guess you like

Origin blog.csdn.net/weixin_38428126/article/details/131603585