我正在查看git历史,发现了一些感兴趣的文件。不幸的是,它已经改名了!有没有一个整洁的方法来发现文件的新路径是什么?
我目前的做法是
[dbn repo]$ git log -- -1 --pretty=oneline old_directory/interesting_file.py
5ee1cf move old_directory files
[dbn repo]$ git log --stat -1 5ee1cf
commit 5ee1cf
Author: oh, it was me, the scoundral <dbn@dbn.dbn>
move old_directory files
{old_directory => new_directory}/interesting_file.py
我可以把它折叠成一行代码,但是move commit可能有一堆我不关心的其他东西。
背景--我现在是手工完成的,但这是我希望编写脚本的一些考古工作的一部分,所以如果能有一个适合脚本的解决方案就好了。
3条答案
按热度按时间z3yyvxxp1#
也许这可以帮助:
git whatchanged
解析“stat”输出的麻烦较少。显然,可以将git-log(1)的
-M
开关传递给git-whatchanged(1)(即控制文件差异检测的东西)。testing
nhaq1z212#
最快的方法就是
然后在搜索结果中寻找你感兴趣的路径。
zc0qhyus3#
如果创建了文件:
...后来,改名为:
你可以找到这样的“重命名”提交:
...并显示更改: