我在存储库中有一堆提交。我想看到两次提交之间更改的文件列表-从SHA1到SHA2。
我应该使用什么命令?
我在存储库中有一堆提交。我想看到两次提交之间更改的文件列表-从SHA1到SHA2。
我应该使用什么命令?
当前回答
正如巧妙的机器人在回答中所说:
git diff --name-status [SHA1 [SHA2]]
我的例子:
git diff --name-status 78a09k12067c24d8f117886c4723ccf111af4997
4b95d595812211553070046bf2ebd807c0862cca
M views/layouts/default.ctp
M webroot/css/theme.css
A webroot/img/theme/logo.png
其他回答
基于gitdiff-name状态,我编写了gitdiffviewGit扩展,该扩展呈现了两个路径之间变化的层次树视图。
但是,如果看到文件在您的分支和它的共同祖先与另一个分支之间发生了更改(例如,origin/master):
git diff --name-only `git merge-base origin/master HEAD`
似乎没有人提到开关--stat:
$ git diff --stat HEAD~5 HEAD
.../java/org/apache/calcite/rex/RexSimplify.java | 50 +++++++++++++++++-----
.../apache/calcite/sql/fun/SqlTrimFunction.java | 2 +-
.../apache/calcite/sql2rel/SqlToRelConverter.java | 16 +++++++
.../org/apache/calcite/util/SaffronProperties.java | 19 ++++----
.../org/apache/calcite/test/RexProgramTest.java | 24 +++++++++++
.../apache/calcite/test/SqlToRelConverterTest.java | 8 ++++
.../apache/calcite/test/SqlToRelConverterTest.xml | 15 +++++++
pom.xml | 2 +-
.../apache/calcite/adapter/spark/SparkRules.java | 7 +--
9 files changed, 117 insertions(+), 26 deletions(-)
还有--numstat
$ git diff --numstat HEAD~5 HEAD
40 10 core/src/main/java/org/apache/calcite/rex/RexSimplify.java
1 1 core/src/main/java/org/apache/calcite/sql/fun/SqlTrimFunction.java
16 0 core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
8 11 core/src/main/java/org/apache/calcite/util/SaffronProperties.java
24 0 core/src/test/java/org/apache/calcite/test/RexProgramTest.java
8 0 core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java
15 0 core/src/test/resources/org/apache/calcite/test/SqlToRelConverterTest.xml
1 1 pom.xml
4 3 spark/src/main/java/org/apache/calcite/adapter/spark/SparkRules.java
和--shortstat
$ git diff --shortstat HEAD~5 HEAD
9 files changed, 117 insertions(+), 26 deletions(-)
git diff --name-status [SHA1 [SHA2]]
类似于--name,只是你得到一个简单的前缀,告诉你文件发生了什么(修改、删除、添加…)
git log --name-status --oneline [SHA1..SHA2]
类似,但提交列在提交消息之后,因此您可以看到文件何时更改。
如果您对某些文件/文件夹发生的情况感兴趣,可以在git日志版本中添加--<filename>[<filename>…]。如果您想查看一次提交发生了什么,请将其称为SHA1,然后执行git log--名称状态--单行[SHA1^..SHA1]
文件状态标志:
Flag | Name | Meaning |
---|---|---|
M |
modified | File has been modified |
C |
copy-edit | File has been copied and modified |
R |
rename-edit | File has been renamed and modified |
A |
added | File has been added |
D |
deleted | File has been deleted |
U |
unmerged | File has conflicts after a merge |
以下内容对我很有用:
git show --name-only --format=tformat: SHA1..SHA2
它也可以用于单个提交:
git show --name-only --format=tformat: SHA1
这对于在Jenkins中使用非常方便,在Jenkins中将为您提供一个变更集SHA哈希值列表,并希望对其进行迭代以查看哪些文件已被更改。
这与前面的几个答案类似,但使用tformat:而不是format:删除了提交之间的分隔符。