是否有可能看到谁在git blame报告的提交之前编辑了特定的行,就像一个给定行的提交历史?

例如,我运行以下(在优秀的uncrustify项目上):

$ git blame -L10,+1 src/options.cpp
^fe25b6d (Ben Gardner 2009-10-17 13:13:55 -0500 10) #include "prototypes.h"

我如何才能找到谁在提交fe25b6d之前编辑了这一行?在提交之前是谁编辑的?


当前回答

您可以使用git log -L来查看一行范围的演变。

例如:

git log -L 15,23:filename.txt

表示“跟踪文件名.txt文件中第15行到第23行的演变”。

其他回答

如果你正在使用JetBrains Idea IDE(和衍生品),你可以选择几行,右键单击上下文菜单,然后Git ->显示历史选择。你将看到影响选定行的提交列表:

你可能想看看:

git gui blame <filename>

给你一个漂亮的图形显示的变化,如“git责备”,但每行可点击的链接,移动到更早的提交。将鼠标悬停在链接上,就会弹出一个包含提交细节的窗口。不是我的学分……在这里找到它:

http://zsoltfabok.com/blog/2012/02/git-blame-line-history/

git gui是git的图形化Tcl/Tc界面。没有任何其他参数,它启动了一个相当简单但有用的图形应用程序,用于提交文件,块甚至单行和其他类似的命令,如修改,恢复,推送…它是git股票套件的一部分。在windows上,它包含在安装程序中。在debian上-我不知道其他*nix系统-它必须单独安装:

apt-get install git-gui

从文档中可以看出:

https://git-scm.com/docs/git-gui

DESCRIPTION A Tcl/Tk based graphical user interface to Git. git gui focuses on allowing users to make changes to their repository by making new commits, amending existing ones, creating branches, performing local merges, and fetching/pushing to remote repositories. Unlike gitk, git gui focuses on commit generation and single file annotation and does not show project history. It does however supply menu actions to start a gitk session from within git gui. git gui is known to work on all popular UNIX systems, Mac OS X, and Windows (under both Cygwin and MSYS). To the extent possible OS specific user interface guidelines are followed, making git gui a fairly native interface for users. COMMANDS blame Start a blame viewer on the specified file on the given version (or working directory if not specified). browser Start a tree browser showing all files in the specified commit. Files selected through the browser are opened in the blame viewer. citool Start git gui and arrange to make exactly one commit before exiting and returning to the shell. The interface is limited to only commit actions, slightly reducing the application’s startup time and simplifying the menubar. version Display the currently running version of git gui.

我写了一个ublame python工具,它可以返回影响给定搜索词的文件提交的简单历史,你可以在þroject页面上找到更多信息。

从Git 2.23开始,你可以使用Git blame——ignore-rev

对于问题中给出的例子,这将是:

git blame -L10,+1 src/options.cpp --ignore-rev fe25b6d

(然而,这是一个棘手的问题,因为fe25b6d是该文件的第一个修订!)

安布尔的回答是正确的,但我觉得不清楚;语法为:

git blame {commit_id} -- {path/to/file}

注意:——用于将树状sha1与相对文件路径分开。1

例如:

git blame master -- index.html

这一切都要归功于安布尔!:)