如何在git中获取分配给文件的所有标记?(How do I get all the tags that are assigned to a file in git?)

编程入门 行业动态 更新时间:2024-10-24 12:27:21
如何在git中获取分配给文件的所有标记?(How do I get all the tags that are assigned to a file in git?)

我需要告诉文件的哪个版本/ SHA1与一个或多个标签相关联。 在CVS中,可以获得类似于此的输出:

文件 :abc.txt Rev :1.0 标签 :R1_0,R1_1

Rev :1.1 标签 :R1_2

如何使用git获取文件标记历史记录

编辑:我经常使用此函数来判断文件的哪个版本正在生产中。 我知道哪个版本(标签)的软件正在生产中。 基于此,我想知道给定文件的哪个版本被标记(以及哪个以前的标记与此文件修订版关联)。

在上面的例子中: R1_1将投入生产。 查询abc.txt,我可以看出,abc.txt的rev1.0用于R1_0和R1_1。 (因此,R1_1中的错误不太可能是由abc.txt引起的,因为它仍然是与R1_0相同的文件)

I need to to tell which revision/SHA1 of a file was associated with one or more tags. In CVS it is possible to get an output similar to to this:

File: abc.txt Rev: 1.0 Tags: R1_0, R1_1

Rev: 1.1 Tags: R1_2

How do you get a tag history for a file with git?

Edit: I frequently use this function to tell which revision of a file is in production. I know which version (tag) of software is in production. Based upon this I would like to know which revision of a given file was tagged (and also which previous tags were associated to this file revision).

In my example above: R1_1 will be in production. Querying abc.txt, I can tell that rev1.0 for abc.txt was used for both R1_0 and R1_1. (Thus unlikely that a new bug in R1_1 was caused by abc.txt because it still the same file as R1_0)

最满意答案

我认为你试图过于具体地将概念从一个版本控制系统转换为另一个版本控制系统。 我问,“自R1_1以来, R1_1有何变化?”

git log R1_1.. -- abc.txt

现在你知道两件事 - 它已经改变了,以及如何改变。 如果你想看到变化,也可以在-p抛出。

没什么用,但你要求的是:

要完全按照你要求做的事情(我认为它不太有用),并假设你正确标记 :

git describe `git log --pretty=format:%H -n 1 abc.txt`

这表明最接近改变文件的最后一次提交的标记名称。

I think you're trying to be too specific in literally translating concepts from one revision control system to another. I'd ask, "how has abc.txt changed since R1_1?"

git log R1_1.. -- abc.txt

Now you know two things -- that it's changed, and how. Toss in a -p if you want to see the changes, too.

Less Helpful, but What You Asked For:

To do exactly what you're asking for (which I think is less useful), and assuming you're tagging properly:

git describe `git log --pretty=format:%H -n 1 abc.txt`

That shows you closest thing to a tag name for the last commit that changed the file.

更多推荐

本文发布于:2023-08-03 19:39:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1396265.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:标记   文件   如何在   git   file

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!