列出Git提交之间的更改状态(添加,修改,删除) [英] List all changed files with change status between Git commits (added, modified, deleted)

查看:128
本文介绍了列出Git提交之间的更改状态(添加,修改,删除)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常使用以下命令列出在两次提交之间更改的文件:

  git diff  - 仅限名称SHA1 SHA2 

它提供了一些文件列表:

 
/ src / example / file1
/ src / example / file2
/ src / example / file3

几乎没有终点,这是多么有用。



我真的很希望能够同时展示每个文件都对变更状态进行简要引用,指出文件是否被添加,修改或删除。



下面是一个演示概念的示例:

  git diff --name-only --and-how-me-the-change-status SHA1 SHA2 



 
A / src / example / file1
M / src / example / file2
D / src / example / file3

更改状态(A,M,D)仅作为示例显示,只要它是明确的,不要在意这是什么。



我知道我可以使用 - diff-filter 选项仅列出添加的文件,或者只列出已修改的文件或只删除文件。使用这个选项意味着我必须运行三个命令来获得三个文件名列表。这很好,但可能会更好。



是否有一个命令可以运行以给出上述示例输出?

解决方案使用 - name-status ,它与 - 仅限名称加上已更改文件的状态:

  git diff --name-状态SHA1 SHA2 


I regularly use the following command to list files changed between two commits:

git diff --name-only SHA1 SHA2

It gives a list of files somewhat like this:

/src/example/file1
/src/example/file2
/src/example/file3

There is almost no end to how useful this is.

I'd really like to be able also to show alongside each file a brief reference to the change status, indicating whether a file was added, modified or deleted.

Here's an example to demonstrate the concept:

git diff --name-only --and-how-me-the-change-status SHA1 SHA2

A /src/example/file1
M /src/example/file2
D /src/example/file3

The change status (A, M, D) is shown as an example only, I don't mind what this is so long as it is unambiguous.

I'm aware that I can use the --diff-filter option to list only added files, or only modified files or only deleted files. Using this option means I have to run three commands to get three lists of filenames. This is nice but could be nicer.

Is there a single command I can run to give me the above example output?

解决方案

Use --name-status, it's the same as --name-only plus the status of changed files:

git diff --name-status SHA1 SHA2

这篇关于列出Git提交之间的更改状态(添加,修改,删除)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆