如何在某个目录上 git diff
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8382019/
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
How do I git diff on a certain directory
提问by priya
git diff actually runs a diff on all source code, how do I do this on a certain directory so that I can view modifications on files underneath it.
git diff 实际上在所有源代码上运行差异,我如何在某个目录上执行此操作,以便我可以查看对其下文件的修改。
采纳答案by Geo
Provide a path ( myfolder in this case ) and just run:
提供一个路径(在本例中为 myfolder )并运行:
git diff myfolder/
git diff myfolder/
回答by bcattle
If you're comparing different branches, you need to use --
to separate a git revision from a filesystem path. For example, with two local branches, master
and bryan-working
:
如果要比较不同的分支,则需要使用--
将 git 修订版与文件系统路径分开。例如,有两个本地分支,master
并且bryan-working
:
$ git diff master -- AFolderOfCode/ bryan-working -- AFolderOfCode/
Or from a local branch to a remote:
或者从本地分支到远程:
$ git diff master -- AFolderOfCode/ origin/master -- AFolderOfCode/
回答by Noufal Ibrahim
You should make a habit of looking at the documentation for stuff like this. It's very useful and will improve your skills very quickly. Here's the relevant bit when you do git help diff
您应该养成查看此类文档的习惯。这是非常有用的,会很快提高你的技能。当你这样做时,这是相关的一点git help diff
git diff [options] [--no-index] [--] <path> <path>
The two <path>
s are what you need to change to the directories in question.
这两个<path>
s 是您需要更改为相关目录的内容。
回答by Barani
Add Beyond Compare as your difftool in git and add alias for diffdir as:
在 git 中添加 Beyond Compare 作为 difftool 并为 diffdir 添加别名:
git config --global alias.diffdir = "difftool --dir-diff --tool=bc3 --no-prompt"
Get the gitdiff as :
获取 gitdiff 为:
git diffdir 4bc7ba80edf6 7f566710c7
参考:https: //truncatedcodr.wordpress.com/2014/09/20/compare-entire-directories-w-git-difftool-beyond-compare/
回答by Ashutosh Jindal
To use Beyond Compare as the difftool for directory diff, remember enable follow symlinks like so:
要将 Beyond Compare 用作目录差异的差异工具,请记住启用如下符号链接:
In a Folder Compare View -> Rules (Referee Icon) :
在文件夹比较视图 -> 规则(裁判图标):
and then, enabled follow symlinks and update session defaults:
然后,启用跟随符号链接并更新会话默认值:
OR, setup the alias like so:
或者,像这样设置别名:
git config --global alias.diffdir "difftool --dir-diff --tool=bc3 --no-prompt --no-symlinks"
Note that in either case, any edits made to the side (left or right) that refers to the current working tree are preserved.
请注意,在任何一种情况下,对引用当前工作树的一侧(左侧或右侧)所做的任何编辑都将保留。