乐闻世界logo
搜索文章和话题

What names are valid git tags?

1个答案

1

In Git, tags are primarily used to mark specific commits, typically for version releases. Git tag names are flexible but must adhere to certain naming rules and best practices.

Valid Git Tag Names

Basic Rules:

  1. No spaces: Tag names should not contain spaces.
  2. Avoid special characters: Although Git allows most characters, it is advisable to avoid special characters such as ^, :, ~, *, ?, [, and @{ that could cause parsing issues.
  3. Do not start with a hyphen (-): This may conflict with Git options.

Common Valid Naming Examples:

  • Version numbers: Such as v1.0, v1.0.1, v2.0-beta1. This is the most common usage, using v as a prefix to separate version numbers.
  • Staged tags: Such as initial, alpha, beta, release, final.
  • Dates: Such as 2021-08-15. If your project uses time-based updates, you can use dates as tags.
  • Features: For major updates targeting specific features, use feature names as tags, such as feature-x, feature-y-update.

Example:

Suppose we have completed the first release of a project; here's how I would proceed:

bash
git tag -a v1.0 -m "Release version 1.0" git push origin v1.0

Here, -a creates an annotated tag, v1.0 is the tag name, and -m is followed by the tag description.

By using such naming conventions and operations, you can clearly manage the project's version history and key milestones, facilitating team members' understanding and collaboration.

2024年6月29日 12:07 回复

你的答案