检索文件中特定行的提交日志? [英] Retrieve the commit log for a specific line in a file?

查看:81
本文介绍了检索文件中特定行的提交日志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么办法让git给你一个提交日志来提交文件中触及特定的提交?



git blame ,但是 git blame 会显示触及特定行的最后一个提交。



我真的很想得到类似的日志,而不是提交到文件中任何地方的提交列表,而只是提交触及特定行的提交。 p>

解决方案

参见




自从Git 1.8。 4 git log has -L 可查看一系列线的演变。



例如,假设您查看 git blame 的输出。这里 -L 150,+ 11 表示只看150到150 + 11行:

  $ git blame  - L 150,+ 11  -  git-web--browse.sh 
a180055a git-web--browse.sh(Giuseppe Bilotta 2010-12-03 17:47:36 +0100 150)dieThe browser $浏览器不是
a180055a git-web--browse.sh(Giuseppe Bilotta 2010-12-03 17:47:36 +0100 151)fi
5d6491c7 git-browse-help.sh(Christian Couder 2007 -12-02 06:07:55 +0100 152)fi
5d6491c7 git-browse-help.sh(Christian Couder 2007-12-02 06:07:55 +0100 153)
5d6491c7 git- browse-help.sh(Christian Couder 2007-12-02 06:07:55 +0100 154)在
81f42f11的情况下$ browsergit-web--browse.sh(Giuseppe Bilotta 2010-12-03 17 :47:38 +0100 155)firefox | iceweasel | seamonkey | iceape)
5d6491c7 git-browse-help.sh(Christian Couder 2007-12-02 06:07:55 +0100 156)#检查版本,因为firefox < 2.0 do
5d6491c7 git-browse-hel p.sh(Christian Couder 2007-12-02 06:07:55 +0100 157)vers = $(expr$($ browser_path -version)
5d6491c7 git-browse-help.sh(Christian Couder 2007 -12-02 06:07:55 +0100 158)NEWTAB =' - new-tab'
5d6491c7 git-browse-help.sh(Christian Couder 2007-12-02 06:07:55 +0100 159)测试$ vers-lt 2&& NEWTAB =''
a0685a4f git-web--browse.sh(Dmitry Potapov 2008-02-09 23:22:22 -0800 160)$ browser_path$ NEWTAB$ @&

并且您想知道现在行155的历史。



然后,使用 git log 。在这里, -L 155,155:git-web--browse.sh 表示在名为 git-web的文件中跟踪155行到155行的演变--browse.sh

  $ git log --pretty = short -u -L 155,155:git-web--browse.sh 
commit 81f42f11496b9117273939c98d270af273c8a463
作者:Giuseppe Bilotta< giuseppe.bilotta@gmail.com>

web - 浏览:支持opera,seamonkey和elinks

diff --git a / git-web--browse.sh b / git-web - browse。 sh
--- a / git-web--browse.sh
+++ b / git-web--browse.sh
@@ -143,1 +143,1 @ @
-firefox | iceweasel)
+ firefox | iceweasel | seamonkey | iceape)

提交a180055a47c6793eaaba6289f623cff32644215b
作者:Giuseppe Bilotta< giuseppe.bilotta@gmail.com> ;

网页浏览:编码风格

diff --git a / git-web--browse.sh b / git-web--browse.sh
--- a / git-web--browse.sh
+++ b / git-web--browse.sh
@@ -142,1 +142,1 @@
- firefox | iceweasel)
+ firefox | iceweasel)

commit 5884f1fe96b33d9666a78e660042b1e3e5f9f4d9
作者:Christian Couder< chriscool@tuxfamily.org>

将'git-help--browse.sh'重命名为'git-web--browse.sh'。

diff --git a / git-web--browse.sh b / git-web--browse.sh
--- / dev / null
+++ b / git-web--browse.sh
@@ -0,0 +127,1 @@
+ firefox | iceweasel)


Is there any way to get git to give you a commit log for just commits that touched a particular line in a file?

Like git blame, but git blame will show you the LAST commit that touched a particular line.

I'd really like to get a similar log of, not the list of commits to anywhere in the file, but just the commits that touched a particular line.

解决方案

See also Git: discover which commits ever touched a range of lines.


Since Git 1.8.4, git log has -L to view the evolution of a range of lines.

For example, suppose you look at git blame's output. Here -L 150,+11 means "only look at the lines 150 to 150+11":

$ git blame -L 150,+11 -- git-web--browse.sh
a180055a git-web--browse.sh (Giuseppe Bilotta 2010-12-03 17:47:36 +0100 150)            die "The browser $browser is not
a180055a git-web--browse.sh (Giuseppe Bilotta 2010-12-03 17:47:36 +0100 151)    fi
5d6491c7 git-browse-help.sh (Christian Couder 2007-12-02 06:07:55 +0100 152) fi
5d6491c7 git-browse-help.sh (Christian Couder 2007-12-02 06:07:55 +0100 153) 
5d6491c7 git-browse-help.sh (Christian Couder 2007-12-02 06:07:55 +0100 154) case "$browser" in
81f42f11 git-web--browse.sh (Giuseppe Bilotta 2010-12-03 17:47:38 +0100 155) firefox|iceweasel|seamonkey|iceape)
5d6491c7 git-browse-help.sh (Christian Couder 2007-12-02 06:07:55 +0100 156)    # Check version because firefox < 2.0 do
5d6491c7 git-browse-help.sh (Christian Couder 2007-12-02 06:07:55 +0100 157)    vers=$(expr "$($browser_path -version)" 
5d6491c7 git-browse-help.sh (Christian Couder 2007-12-02 06:07:55 +0100 158)    NEWTAB='-new-tab'
5d6491c7 git-browse-help.sh (Christian Couder 2007-12-02 06:07:55 +0100 159)    test "$vers" -lt 2 && NEWTAB=''
a0685a4f git-web--browse.sh (Dmitry Potapov   2008-02-09 23:22:22 -0800 160)    "$browser_path" $NEWTAB "$@" &

And you want to know the history of what is now line 155.

Then, use git log. Here, -L 155,155:git-web--browse.sh means "trace the evolution of lines 155 to 155 in the file named git-web--browse.sh".

$ git log --pretty=short -u -L 155,155:git-web--browse.sh
commit 81f42f11496b9117273939c98d270af273c8a463
Author: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>

    web--browse: support opera, seamonkey and elinks

diff --git a/git-web--browse.sh b/git-web--browse.sh
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
@@ -143,1 +143,1 @@
-firefox|iceweasel)
+firefox|iceweasel|seamonkey|iceape)

commit a180055a47c6793eaaba6289f623cff32644215b
Author: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>

    web--browse: coding style

diff --git a/git-web--browse.sh b/git-web--browse.sh
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
@@ -142,1 +142,1 @@
-    firefox|iceweasel)
+firefox|iceweasel)

commit 5884f1fe96b33d9666a78e660042b1e3e5f9f4d9
Author: Christian Couder <chriscool@tuxfamily.org>

    Rename 'git-help--browse.sh' to 'git-web--browse.sh'.

diff --git a/git-web--browse.sh b/git-web--browse.sh
--- /dev/null
+++ b/git-web--browse.sh
@@ -0,0 +127,1 @@
+    firefox|iceweasel)

这篇关于检索文件中特定行的提交日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆