简体   繁体   English

如何在git中查看特定提交中的文件?

[英]How to see files in a particular commit in git?

我想查看在git中的特定提交中提交的所有文件,我该怎么做?

You can use git show --pretty="format:" --name-only <commit_id> . 您可以使用git show --pretty="format:" --name-only <commit_id> This will list all the files that were committed in a particular commit. 这将列出在特定提交中提交的所有文件。

There are number of ways to do this 有很多方法可以做到这一点

Method 1: git show --name-only {commit} 方法1: git show --name-only {commit}

Example - git show --name-only a303aa90779efdd2f6b9d90693e2cbbbe4613c1d 示例git show --name-only a303aa90779efdd2f6b9d90693e2cbbbe4613c1d

Method 2: Method 1 will give you a lot of additional diff information and in case you are only interested in looking at ONLY the files that were changedthen you can use this- 方法2:方法1将为您提供许多其他差异信息,如果您只想查看已更改的文件,则可以使用此方法-

Example git diff-tree --no-commit-id --name-only -r fv42bi45 例子git diff-tree --no-commit-id --name-only -r fv42bi45

Method 3: You can also use this as an alternate to Method 2. Example git show --pretty="format:" --name-only fv42bi45 方法3:您也可以使用它作为方法2的替代方法。示例git show --pretty="format:" --name-only fv42bi45

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM