如何使用git log仅获取具有路径的文件名? [英] How to get ONLY filename with path using git log?
问题描述
我几乎使用了所有的git log命令,但是我还没有找到执行此操作的最佳方法.我只需要这个-只获取带有路径的文件名
I used almost all git log commands yet i haven't found a best way to do this. I need only this - get only file name with path nothing else
/path/filename.txt
/path/anotherfile.ext
...
...
我的输入是git log命令的日期FROM和TO. git log会提供开发人员名称或日期或提交编号,或者提供我不希望使用的文件名.如何仅获取具有完整路径的文件名?
My input is date FROM and TO to the git log command. Either git log gives developer-name or date or commit-number or something that i don't want with file names. How to get ONLY the file name with full path?
推荐答案
使用--since
和--until
选项选择时间范围,然后可以使用UNIX管道将grep
,sort
收集起来. uniq
e条路径:
Use the --since
and --until
options to select the time range and then you can use UNIX pipes to grep
, sort
and collect the uniq
e paths:
git log --name-status --since='..' --until='..' | grep -E '^[A-Z]\b' | sort | uniq | sed -e 's/^\w\t*\ *//'
示例:
git log --name-status --since='1 January 2015' --until='2 January 2015' | grep -E '^[A-Z]\b' | sort | uniq | sed -e 's/^\w\t*\ *//'
有关更详细的git log
输出,请参见如何让git log显示文件名,如svn log -v
For more detailed git log
outputs see How to have git log show filenames like svn log -v
如果必须提交哈希,则也可以使用git diff
和--name-only
来代替,如其他答案所述:
If you have to commit hashes, you can also use git diff
and --name-only
instead, as the other answer mentions:
git diff hash1..hash2 --name-only
这篇关于如何使用git log仅获取具有路径的文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!