git - 使用 Git 时找出谁提交了特定代码段的最快方法是什么?

标签 git

在使用 Git 时找出谁提交了特定代码段的最快方法是什么?

最佳答案

您可以使用git blame <filename> 。您将看到文件的每个代码片段的作者姓名、时间标签和提交。

这是您可以在 gitblame 的手册页上找到的语法:

usage: git blame [<options>] [<rev-opts>] [<rev>] [--] <file>

<rev-opts> are documented in git-rev-list(1)

--incremental         Show blame entries as we find them, incrementally
-b                    Show blank SHA-1 for boundary commits (Default: off)
--root                Do not treat root commits as boundaries (Default: off)
--show-stats          Show work cost statistics
--progress            Force progress reporting
--score-debug         Show output score for blame entries
-f, --show-name       Show original filename (Default: auto)
-n, --show-number     Show original linenumber (Default: off)
-p, --porcelain       Show in a format designed for machine consumption
--line-porcelain      Show porcelain format with per-line commit information
-c                    Use the same output mode as git-annotate (Default: off)
-t                    Show raw timestamp (Default: off)
-l                    Show long commit SHA1 (Default: off)
-s                    Suppress author name and timestamp (Default: off)
-e, --show-email      Show author email instead of name (Default: off)
-w                    Ignore whitespace differences
--indent-heuristic    Use an experimental indent-based heuristic to improve diffs
--compaction-heuristic
                      Use an experimental blank-line-based heuristic to improve diffs
--minimal             Spend extra cycles to find better match
-S <file>             Use revisions from <file> instead of calling git-rev-list
--contents <file>     Use <file>'s contents as the final image
-C[<score>]           Find line copies within and across files
-M[<score>]           Find line movements within and across files
-L <n,m>              Process only line range n,m, counting from 1
--abbrev[=<n>]        use <n> digits to display SHA-1s

关于git - 使用 Git 时找出谁提交了特定代码段的最快方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48139709/

相关文章:

Git:在 "git rm"之后推送更改

git - git clone 和 checkout 有什么区别?

git - 撤消自上次推送以来 git 中的更改?

git - 在主分支上维护数百个定制分支

git:重置到远程分支

git - libchromiumcontent创建补丁文件

git - 是否可以从 Github 网站或 API 获取 merge 到分支的列表?

python - 从另一个仓库导入 python 模块

linux - 如何查看标签的年龄?

git - 监视文件更改并在新文件出现时调用 git commit