如何找到提交的分支?(How to find the branch of a commit?)

编程入门 行业动态 更新时间:2024-10-28 09:14:28
如何找到提交的分支?(How to find the branch of a commit?)

当我在我当地的回购中并做

git show <commit-SHA>

它向我显示了提交及其相关文件的更改。

但是git会在repo中的所有分支上进行搜索,而不仅仅是我当前所在的分支。如何让它显示在提交的本地分支中?

When I am in my local repo and do

git show <commit-SHA>

it shows me the commit and its associated file changes.

But git does a search across all branches in the repo, not just the branch I am currently in. How do I get it to display in which of the local branches that commit is located?

最满意答案

如果您想知道哪些分支包含提交,您可以使用

git branch --contains COMMIT_ID

这将向您显示跟踪其历史记录返回给定提交的所有分支。

顺便说一下,git没有“搜索所有分支”来查找git show的提交; SHA1总和的要点是Git可以立即转到相关对象,因为它的内容永远不会改变。

If you want to know which branches contain a commit, you can use

git branch --contains COMMIT_ID

This will show you all branches that an trace their history back to the given commit.

As an aside, git doesn't do a "search across all branches" to find a commit for git show; The point of the SHA1 sum is that Git can go immediately to the object in question because its content can never change.

更多推荐

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

发布评论

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

>www.elefans.com

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