git 分支之间某个文件夹的差异

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

Differences for a certain folder between git branches

gitversion-controldiffgit-diff

提问by Wazery

As in the title, I want to have a diff file for a certain folder between the master branch and a branch I have created.

如标题所示,我希望在 master 分支和我创建的分支之间的某个文件夹中有一个 diff 文件。

回答by jolivier

You can use

您可以使用

git diff master..yourbranch path/to/folder

回答by Sergiu Dumitriu

git diffcompares trees (as in hierarchies of source files at two different points in time), so it can't extract the changes done by a certain author. If you want to see what changes a user committed, then you need git log.

git diff比较树(如在两个不同时间点的源文件层次结构),因此它无法提取某个作者所做的更改。如果您想查看用户提交的更改,那么您需要git log.

Does this solve your need?

这能解决您的需求吗?

git log --author=jdoe oldbranch..newbranch -p -- path/to/subdirectory > myChangesInSubdirectory.patch

This lists each commit done by jdoebetween the two commits, printing them as a patch instead of the usual commit summary, limiting only to commits that have changes in the target subdirectory, and redirects the output to a file.

这列出了jdoe在两次提交之间完成的每个提交,将它们打印为补丁而不是通常的提交摘要,仅限于在目标子目录中有更改的提交,并将输出重定向到文件。