Why git tag a blob or a tree (or a tag)?

时间秒杀一切 提交于 2019-12-30 09:33:02

问题


I understand how it is possible to tag a blob, or a tree, or even another annotated tag, using a git tag. I understand the architecture and conceptual design that makes this possible.

However, I'm having trouble thinking of real life applications of this (or "real workflow" applications).

Searching here on Stack Overflow I only found one answer that mentions tagging non-commit objects, with advice not to do so.

Under what possible circumstances could it ever be appropriate to tag a non-commit object?


回答1:


Tagging trees or blobs may be appropriate temporarily in long-running utility programs that manipulate objects directly. Tagging would ensure that git gc can be safely run in parallel. The utility program would then remove the tags when it's done, when it's created a commit.




回答2:


Are there any use cases where it would be appropriate to tag a non-commit object?

As you figured out. In a nutshell you should avoid non-commit tagging.

Lets say for example that you have fixed a code (hot fix) and its part of a bigger commit

Why?
since it was committed like this and only later you figured out that you need only a single file.
Now you want to mark the file (content) of this change without marking all the other content.

Sample 2:
You are going over the code trying to figure out which file caused a bug, to mark a single commit you can use a tag or a git note but to mark a single file you will use tag.

And there can some other examples as well.


The Linux kernel repository also has a non-commit-pointing tag object – the first tag created points to the initial tree of the import of the source code



来源:https://stackoverflow.com/questions/36112726/why-git-tag-a-blob-or-a-tree-or-a-tag

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!