有没有办法在 Git 的一个分支上查看所有更改的文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6913263/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 05:46:02  来源:igfitidea点击:

Is there a way to see all changed files on a branch in Git?

git

提问by screenm0nkey

I apolagise if this isn't very clear but in Git, is there a way to see all changed files on a branch, by name only. As far as I know I can use git log to see files that have changed in a single commit but I want to see all files that have changed since the branch was created, over several commits.

如果这不是很清楚,我很抱歉,但在 Git 中,有没有办法仅按名称查看分支上所有更改的文件。据我所知,我可以使用 git log 查看在一次提交中发生更改的文件,但我想查看自分支创建以来在多次提交中发生更改的所有文件。

There is git diff but this also lists the changed files in the branch I'm comparing to which I don't want to see. I kind of want a command that says 'show me file names for all changed files in this branch'.

有 git diff 但这也列出了我正在比较的分支中我不想看到的已更改文件。我有点想要一个命令,上面写着“显示这个分支中所有更改文件的文件名”。

Many thanks

非常感谢

回答by Mark Longair

Supposing you're on branch foo, and you're interested in which files have changed since the point when it diverged from master, you can just do:

假设您在 branch 上foo,并且您对自与分叉后哪些文件发生了变化感兴趣master,您可以这样做:

git diff --name-only master...

(Note the three dots.) If you're not foo, you can use the full form:

(注意三个点。)如果你不是foo,你可以使用完整的形式:

git diff --name-only master...foo

I made some graphics that explain the double-dot and triple-dot notations, and their differences between their meaning in git rev-listand git log- you can find them in this answer.

我制作了一些图形来解释双点和三点符号,以及它们在git rev-list和 中的含义之间的差异git log- 您可以在这个答案中找到它们。

回答by antlersoft

Don't know that there is something that does exactly what you want based only on your current branch, but if you know the commit id that is the parent of your branch, you can do:

不知道有什么东西可以根据您当前的分支完全满足您的需求,但是如果您知道作为您的分支的父级的提交 ID,您可以执行以下操作:

git diff --name-only <commit id of branch point>..HEAD

回答by nocache

Assuming you have checked out the branch you are working on, and you want to compare it to master:

假设您已经检查了您正在处理的分支,并且您想将它与 master 进行比较:

git diff --name-only master

回答by Pawan Maheshwari

I am using this command to find out the list of N files changed between two versions, here N is 50

我用这个命令找出两个版本之间变化的N个文件的列表,这里N是50

git log  --pretty=format: --name-only <SourceBranch>...<TargetBranch> | sort | uniq -c | sort -rg | head -50