问题描述
我只是偶尔的git用户,现在我遇到了一个我无法理解的问题:
I am just an occasional git user, and now I have a problem that is beyond my knowledge:
假设有一个git存储库,没有分支,只有标签.对于给定的两个标签.我需要获取存储库中所有文件的列表,每个文件后接两个数字:两个标签之间添加到特定文件的行数,以及两个标签之间从同一文件删除的行数.
Let's say there is a git repository, no branches, just tags. For given two tags. I need to get the list of all files in the reposotory, each followed by two numbers: number of lines added to the particular file between two tags, and number of lines deleted from the same file between the two tags.
我在网上搜索,但仅找到解决与贡献者相关的类似问题的解决方案,而不是文件.
I searched online, but I found only solutions for similar problem that deals with contributor, not files.
推荐答案
您可以使用 与 --numstat
选项以显示两个标记之间的每个修改文件的以十进制表示的添加和删除的行数".
You can use git diff
with the --numstat
option to show "number of added and deleted lines in decimal notation" for each modified file between the two tags.
git diff tag1 tag2 --numstat
从 git文档:
1 2 README
3 1 arch/{i386 => x86}/Makefile
也就是说,从左到右:
- 添加的行数;
- 标签;
- 已删除的行数;
- 标签;
- 路径名(可能带有重命名/复制信息);
- 换行符.
- the number of added lines;
- a tab;
- the number of deleted lines;
- a tab;
- pathname (possibly with rename/copy information);
- a newline.
这篇关于关于两个标签之间所有文件的Git统计信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!