从提交 ID 中找到一个或多个 git 分支

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2846843/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 04:16:52  来源:igfitidea点击:

Find the git branch or branches from commit id

gitcommitsha1git-branchblame

提问by Senthil A Kumar

Actually am try to get a report on merge conflicts. I used 'git blame' to see who has changed what line, but i couldn't find the branch and repository name information.

实际上我试图获得关于合并冲突的报告。我使用 'git blame' 来查看谁更改了哪一行,但是我找不到分支和存储库名称信息。

Is there a way to find the repository name, branch name and author name of a file from 'git blame' or from commit ids' so that whenever a merge conflict occurs i can send an email to the authors who have touched that file/lines to resolve it.

有没有办法从“gitblame”或“commit ids”中找到文件的存储库名称、分支名称和作者姓名,以便每当发生合并冲突时,我都可以向接触过该文件/行的作者发送电子邮件来解决它。

采纳答案by VonC

git blameshould only give you the revision and author, but:

git blame应该只给你修订版和作者,但是:

  • as mentioned in "Git: Finding what branch a commit came from", you cannot easily pinpoint the branch where that commit has been made (branches can be renamed, moved, deleted...), even though git branch --contains <commit>is a start.
  • I doubt you can find the repository it came from (unless maybe by looking hard in the git logresults, trying to find the parent of that commit comming from a ref/remotesnamespace).
  • 正如“ Git:查找提交来自哪个分支”中所述,即使git branch --contains <commit>是一个开始,您也无法轻松确定进行该提交的分支(可以重命名、移动、删除分支...)。
  • 我怀疑您是否可以找到它来自的存储库(除非可能通过仔细查看git log结果,试图找到来自ref/remotes命名空间的该提交的父项)。

Now if you have a proper .mailmapat the toplevel of the repository, you will have the right email addresses as well.

现在,如果您.mailmap在存储库的顶级有一个合适的,您也将拥有正确的电子邮件地址。

In the simple form, each line in the file consists of a canonical real name of an author, a whitespace, and an email address used in the commit (enclosed by <and >) to map to the name. For example:

在简单形式中,文件中的每一行都包含作者的规范真实姓名、空格和提交中使用的电子邮件地址(由<和括起来>)以映射到该姓名。例如:

Proper Name <[email protected]>