是否有一种方法可以查看分支中哪些文件发生了更改?


当前回答

2020年11月更新:

要获得当前分支中修改(并提交!)的文件列表,您可以使用使用标准git的最短控制台命令:

Git diff -name-only master…


If your local "master" branch is outdated (behind the remote), add a remote name (assuming it is "origin"): git diff --name-only origin/master... If you want to include uncommitted changes as well, remove the ...: git diff --name-only master If you use different main branch name (eg: "main"), substitute it: git diff --name-only main... If your want to output to stdout (so its copyable): git diff --name-only master... | cat If your want filenames to be clickable in VSCode terminal no matter what folder you are running this command from, add --relative: git diff --name-only --relative master... | cat


每个非常好的详细解释不同的选项https://blog.jpalardy.com/posts/git-how-to-find-modified-files-on-a-branch/

其他回答

你所要做的就是:

git checkout <notMainDev>
git diff --name-only <mainDev>

这将只显示两个分支之间不同的文件名。

git show --stat origin/branch_name

这将为您提供在该分支下添加或修改的文件列表。

Git什么改变似乎是一个很好的选择。

真不敢相信有这么多方法可以做到。我使用之前有人发布的whatchanged,只是带有以下参数:

git whatchanged --name-only --pretty="" origin..HEAD

这只列出了文件名,并且只列出了在当前分支上更改的文件名。

@Marco Ponti的另一个答案,避免结帐:

git diff --name-only <notMainDev> $(git merge-base <notMainDev> <mainDev>)

如果您的特定shell不理解$()结构,则使用反引号代替。