找出文件中特定行中的所有GIT更改 [英] Find out all GIT changes in a certain line in a file

查看:100
本文介绍了找出文件中特定行中的所有GIT更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一行代码最近被更改为非工作状态。



我怎样才能找出谁在哪些提交中改变了这一特定行?



我试过

  git log -Sone_distinct_string_from_that_line --pretty = format :'%h%an  - %s  - %ad'

显示所有提交的评论和作者,改变任何一行包含one_distinct_string_from_that_line,但我怎么能看到他们所做的实际更改?

编辑:

我也安装了 git-gui 并查看了 git gui blame filename 的行,但该行只有一个提交更改显示,虽然肯定有更多的变化。

我检查了图形gui smartgit手动查看对该文件所做的所有更改,并且发现了3个提交,其中该行是明确编辑的(首先被删除,然后在另一个com中再次添加)



是否有另一种方法不会在git blame功能上进行中继,并且不会假设该行处于提交-diff?

解决方案

git blame 。 -L选项需要一系列的行,你可以选择一个文件作为git log。因此, git blame -L 10,20 - my / file.txt 会显示最近触及该文件中每一行的git commit。 git gui blame my / file.txt 完成相同的工作,但带有一个UI让您及时浏览。


I have a line of code that was changed recently into a non-working state.

How can I find out who and in which commit changed this particular line?

I tried

git log -Sone_distinct_string_from_that_line --pretty=format:'%h %an -- %s -- %ad'

Which shows all commits with comments and authors that changed anything where a line contained "one_distinct_string_from_that_line", but how can I see the actual changes they made?

EDIT:
I also installed git-gui and looked at the line with git gui blame filename but there is only one commit change for that line shown, although there definitely have been more changes.

I checked with the graphical gui smartgit to look through all changes made on that file by hand and I found 3 commits, where that line was definitely edited (a # was first removed and then in another commit added again)

Is there another way that doesn't relay on the git blame functionality, and doesn't relay on the assumption, that the line is in the commit-diff?

解决方案

git blame. The -L option takes a range of lines and you can select a file as for git log. So git blame -L 10,20 -- my/file.txt will show the most recent git commit that touched each of the lines in that file. git gui blame my/file.txt does the same job but with a UI to let you browse back in time.

这篇关于找出文件中特定行中的所有GIT更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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