简体   繁体   English

查找删除两个修订之间的界线的提交

[英]Find commit that deleted a line between two revision

I am trying to find the commit that deleted a line between between two revisions. 我试图找到删除两个修订版之间的线的提交。 I could not find it directly. 我找不到直接。

This is what I tried in the following: 这是我在以下尝试的方法:

git blame $v1..$v2 -L $line,+1 --reverse -- $file_name

then this command line returns the line that was deleted and not the commit in question. 然后此命令行返回已删除的行,而不是相关的提交。 I searching for this character string using these methods: 我使用以下方法搜索此字符串:

1- Search in commits that have modified the function where the line is. 1-搜索已修改行所在位置的提交。

git show $commit:$file | grep -Fq "$st"

2- Searching using the character string. 2-使用字符串搜索。

git log $v1...$v2 --pretty=format:"%h"  -S"$String" $file

In the first, I could not find the function containing that line (or it doesn't exist) in some cases. 在第一种情况下,我找不到包含该行的函数(或者它不存在)。 In the second approach, The string could be repeated in several cases and I need to review all of them. 在第二种方法中,在某些情况下可以重复使用字符串,因此我需要复查所有字符串。

I need a better way to find the commit that deleted the line. 我需要一种更好的方法来查找删除该行的提交。

I usually use a pickaxe search 我通常使用鹤嘴search搜索

git log -SFoo -- path_containing_change 

That lists commits which introduced the string Foo, but also the commits where Foo was deleted . 该列表列出了引入字符串Foo的提交,还列出了删除 Foo的提交。
Yes, with that approach you need to review those commits in order to determine which one add or remove Foo . 是的,使用这种方法,您需要检查那些提交,以确定添加还是删除了Foo

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM