There is no local push, in Git. After typing tag, the local warehouse only put tag push. Is the remote warehouse the latest code under the tag?

there is no push, locally in Git. After typing tag, the local warehouse only uses tag push. Is the remote warehouse the latest code under this tag?

Git
Mar.14,2022

this question is fun and simple, as long as you do it yourself, you can find that the code under the tag is up-to-date. But to figure out why, You also need to understand objects and refers to these two concepts.

Git has four types of objects: data object (blob object), tree object (tree object), submission object (commit object), and tag object (tag object). The label object is very similar to the submission object and can be understood as a reference to the submission object. Every time we run the git add and git commit commands, we actually save the overwritten file as a data object and a tree object, and create a tree object that points to the top level, which are stored in the .git / objects directory.

secondly, Git has three types of references: HEAD reference , tag reference and remote reference , which are stored in the refs/heads , refs/tags and refs/remotes directories, respectively. The HEAD reference represents the branch of code you create, and the tag reference represents all the tags you create. You can open the files in three directories, which is actually a plain text file that records the SHA-1 hash value of the submitted object (or tag object), indicating which commit the reference points to.

so, when you push a tag to the remote repository, you create a tag reference in the refs/tags directory of the remote repository, which points to a submission object that will be packaged and sent to the server because you don't have push, yet. However, because the HEAD reference is not updated, the submission cannot be seen in any branch that checkout goes to, and can only be seen by checkout to the specified tag,.


is up to date.

git add .
git commit -m 'test'
git tag 'v1.0.0'
git push --tags

if you do this, submissions annotated as test in the remote repository will only appear in tag v1.0.0

Menu