Git Tag

MAJOR version: when you make incompatible API changes
MINOR version: when you add functionality in a backwards compatible manner
PATCH version: when you make backwards compatible bug fixes

1. List Tags

# List all tags
git tag

# Search tags
git tag -l "v1.8.*"

2. Create Tags

  • Lightweight Tag: It's just a pointer to a specific commit.
  • Annotated Tag: When you want to have a tag information.

Create Lightweight Tag

# Create
git tag v0.1.1

# Tag later
git tag v0.1.1 f9ceb02

# Show tag info
git show v0.1.1  # Only Commit message will be seen.

Create Annotated Tag

# Create with message
git tag -a v0.1.1 -m "version message"  # If you don not specify with '-m', git will launch your editor so you can type it in.

# Tag later
git tag -a v0.1.1 f9ceb02

# Show tag info
git show v0.1.1  # Tag message and Commit message will be seen.

3. Share Tags (Push/Fetch Tags)

By default, the git push command doesn't transfer tags to remote servers.

# Push the specified tag
git push origin v0.1.1

# Push all of your tags
git push origin --tags

# Fetch all tags from origin
git fetch origin --tags

4. Delete Tags

# Delete local tags
git tag -d v0.1.1

# Delete remote tags
git push origin --delete v0.1.1

5. Checkout Tags

git checkout v0.1.1

# create a new branch based on specified tag
git checkout -b branchName v0.1.1
posted @ 2023-03-07 18:30  shendawei  阅读(20)  评论(0)    收藏  举报