【发布时间】:2013-11-21 09:50:38
【问题描述】:
我想知道我在哪个提交中添加了下面给出的代码:
if (getListView().getChildCount() == 0)
getActivity().findViewById(android.R.id.empty).setVisibility(View.VISIBLE);
我如何做到这一点?
【问题讨论】:
标签: git git-commit
我想知道我在哪个提交中添加了下面给出的代码:
if (getListView().getChildCount() == 0)
getActivity().findViewById(android.R.id.empty).setVisibility(View.VISIBLE);
我如何做到这一点?
【问题讨论】:
标签: git git-commit
git log -S searchTerm
为您提供引入搜索词的提交。
【讨论】:
在文件上运行git blame。它会向您显示每行的提交 ID、日期和时间以及提交者。然后只需复制提交标识符,您就可以在git log <commit> 或git show <commit> 中使用它。
例如,我有一个名为 test.txt 的文件,在不同的提交中添加了行:
$ cat test.txt
First line.
Second line.
运行git blame:
$ git blame test.txt
^410c3dd (Leigh 2013-11-09 12:00:00 1) First line.
2365eb7d (Leigh 2013-11-09 12:00:10 2) Second line.
第一位是提交ID,然后是名称,然后是日期、时间、时区,最后是行号和行内容。
【讨论】:
git blame test.txt | grep 'First line'
有比对整个文件发出责备更快的方法。如果该行是${lineno},文件是${filename},您可以:
git blame -L ${lineno},${lineno} ${filename}
例子:
git blame -L 2,2 test.txt
【讨论】:
git log -S "mention here line of code" [file-path]
例如:
git log -S "First line" test.txt
提供文件名及其路径是显而易见的,因为大多数时候,我们想知道是谁在特定文件中引入了特定代码段。
【讨论】:
git log -S 'some code' path/to/file.c