查找添加文件的提交(Find commit where file was added)
说我有一段时间以前提交的文件foo.js 我想简单地找到这个文件首次添加的提交。
在阅读答案和我自己的修补之后,这对我有用
git log --follow --diff-filter=A --find-renames=40% foo.jsSay I have a file foo.js that was committed some time ago. I would like to simply find the commit where this file was first added.
After reading the answers and my own tinkering, this works for me
git log --follow --diff-filter=A --find-renames=40% foo.js最满意答案
这样比较简单,“纯git”的做法,无需管道:
git log --diff-filter=A -- foo.js检查文档,您可以对删除,修改等进行相同的操作。
我有一个方便的别名,因为我总是忘记它:
git config --global alias.whatadded 'log --diff-filter=A'这使得它简单如下:
git whatadded -- foo.jsHere's simpler, "pure git" way to do it, no pipeline needed:
git log --diff-filter=A -- foo.jsCheck the docs, you can do the same thing for Deleted, Modified, etc.
https://git-scm.com/docs/git-log#Documentation/git-log.txt---diff-filterACDMRTUXB82308203
I have a handy alias for this because I always forget it:
git config --global alias.whatadded 'log --diff-filter=A'This makes it as simple as:
git whatadded -- foo.js
更多推荐
发布评论