git 如何在git中查找从一个提交更改为另一个提交的文件数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6583917/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to find the number of files changed from one commit to another in git
提问by Talespin_Kit
I am working on a git repository which contains huge number of files changed b/w one commit to another, how to extract the number of files changes b/w commits.
我正在处理一个 git 存储库,其中包含大量更改的文件,一个提交到另一个提交,如何提取文件更改 b/w 提交的数量。
回答by Kerrek SB
The git whatchanged
tool shows you a summary of files that were modified. By itself it lists all commits, but you can also limit it to just the recent ncommits:
该git whatchanged
工具向您显示已修改文件的摘要。它本身列出了所有提交,但您也可以将其限制为最近的n 次提交:
git whatchanged -1
To count files:
要计算文件:
git whatchanged -1 --format=oneline | wc -l
See git help whatchanged
for details.
见git help whatchanged
的详细信息。
回答by yasouser
Apart from the above listed methods you can do this too:
除了上面列出的方法,你也可以这样做:
git diff HEAD^..HEAD --name-only
- will give the list of files changed between HEAD
and one revision before HEAD (HEAD^
). You can replace HEAD^
with a SHA1 of the "from" commit and HEAD
with the SHA1 of the "to" commit:
git diff HEAD^..HEAD --name-only
- 将给出HEAD
在 HEAD ( HEAD^
)之前的一个修订版之间更改的文件列表。您可以用HEAD^
“from”提交HEAD
的 SHA1 和“to”提交的 SHA1替换:
git diff <SHA1-of-from-commit>..<SHA1-of-to-commit> --name-only
git diff <SHA1-of-from-commit>..<SHA1-of-to-commit> --name-only
So if you pipe the output to wc -l
it should give you the number of files changed between commits.
因此,如果您将输出通过管道传递给wc -l
它,则应该为您提供在提交之间更改的文件数。
回答by georgeok
git show --stat
This gives the list of files changed like this:
这给出了如下更改的文件列表:
1 file changed, 1 insertion(+), 1 deletion(-)
1 个文件更改,1 个插入(+),1 个删除(-)
Optionally you can add the commit code if you don't want to get the information from the latest.
如果您不想从最新的信息中获取信息,您可以选择添加提交代码。
git show --stat {commit code without brackets}
回答by c00kiemon5ter
use this:
用这个:
git log --oneline --name-status <HASH> -1
eg:
例如:
$ git log --oneline --name-status bb3ae49 -1
M .vim/spell/en.utf-8.add
M .vim/spell/en.utf-8.add.spl
this works just like
这就像
git whatchanged --oneline --name-status <HASH> -1
回答by osoblanco
In windows:
在窗口中:
git whatchanged -1 --format=oneline | find /v /c ""
The important windows-specific piece is that you must replace the wc command used in other solutions with this:
重要的特定于 Windows 的部分是您必须将其他解决方案中使用的 wc 命令替换为:
| find /v /c ""