Hongmu Notes

Git tag command

A label is a fixed name given to a commit. It is much more convenient to use it when releasing a version than to remember a long list of numbers.
100% Browser local processing 0 Data upload

🌿 Command assembly

💡 Instructions for use

  • The branch name and remote name must be written correctly. Misspelled commands often do not report an error but take effect on other branches.
  • Commands involving reset, force push, and rebase will rewrite history. Please confirm the branch and target before execution.
  • Check Bind Upstream when pushing a new branch for the first time. You can omit the remote and branch names for subsequent pushes and pulls.
  • The command is output in a single line, making it easy to paste directly into the terminal; it is recommended to save the steps that need to be repeated into a script.

A label is a fixed name given to a commit. It is much more convenient to use it when releasing a version than to remember a long list of numbers.

The difference between the two labels

A lightweight tag is just a name pointing to a submission, which is fast to create and contains less information; a tag with a description will generate an additional independent object, including the person who tagged the tag, the time and the description text. It is recommended to use the latter for release versions, because it can explain "who released this version when", making it easier to trace later and facilitate signature verification.

Tag historical commits

I forgot to tag it when publishing, and later found that the version had been submitted several times, so there was no need to roll back. As long as you still remember the submission number, you can add a tag to the specified submission and it will be recorded correctly remotely. Reprinting tags with explanations is also applicable, and will not affect the existing history, which is much safer than redoing the submission.

Why should labels be pushed separately?

Tags will not be automatically uploaded when pushing a branch. This is a deliberate design: Tags are often used to mark releases and should not be created or overwritten at will. When publishing is required, explicitly push specified tags, or push all local tags at once. If you only push the branch but forget to push the tag, others can see the branch but not the version tag, which can easily cause misunderstandings.

Naming and deletion

It is recommended that the version number be written in the popular three-part format, such as major version, minor version and revision number, with a pre-release suffix added when necessary. Deleting the local label will not affect the remote label. To delete the remote label, you must perform a separate push deletion. Once the name is released, try not to change it, because changing the name is equivalent to releasing a version that does not exist.

Use tags with descriptions for release versions, and remember to push the tags to the remote separately.

📖 Glossary

workspace
The directory where the file being edited is located. The modified content that has not yet been registered only exists in the workspace and may be overwritten by any rollback, so important changes must be submitted first.
Staging area
A preparation area between the work area and the warehouse. Submissions only record the contents of the staging area, so a batch of changes can be split into several submissions, or only part of them can be submitted.
Submit
Solidify the contents of the temporary storage area into a historical node, with description, author and time. Once a submission is generated, it has a unique number, which is used as the minimum unit for rollback and tracing.
branch
A movable pointer to a commit, used for parallel development of changes that do not affect each other. A new branch takes up almost no space. Switching branches means that the work area and temporary storage area follow the pointer.
head pointer
A pointer that marks the current location, usually pointing to a branch. If it points directly to a commit and is not on a branch, it is a detached head state, and the new commit at this time will not update any branches.
merge
Merge the history of another branch into the current branch to generate a new merge node. If the two branches do not diverge, they will be fast forwarded directly and no merge node will be generated.
Rebase
Move a series of commits on the current branch to another branch and replay, so the history becomes a straight line. Do not rebase the submitted commits that have been pushed out, otherwise the local history of the collaborators will be inconsistent.
reset
Move the current branch pointer to the specified commit. The three modes respectively determine whether to modify the staging area and the work area at the same time. The mode of changing the work area will directly discard uncommitted modifications.
Remote warehouse
A copy of the same repository located on the server, referenced locally by a name. You can change the address or name of the same remote. Both push and pull are addressed by name.
upstream branch
Establish a corresponding relationship between the local branch and the remote branch. You can omit the remote name and branch name when pushing and pulling after binding, and you can also directly see how many commits are ahead or behind.
label
A fixed name given to a commit, often used to mark versions. Tags with descriptions will generate an additional object containing the author and time. This is recommended for release versions.
storage
Put away unfinished changes temporarily to return the workspace to a clean state and retrieve them when needed. It is suitable for situations where you are called to fix an urgent problem midway but do not want to submit it hastily.

🔗 All keywords and tutorials

Keywords page of the tool12a

Return to tool home page

❓ FAQ

What is the difference between tags and branches?
The branch will move forward with new commits, and the label will be fixed on a certain commit and will not change.
Will deleting tags affect submission??
No. The tag is just a name, and the submission itself and history will not be affected at all after deletion.