git difftool,立即打开所有差异文件,而不是串行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1220309/
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
git difftool, open all diff files immediately, not in serial
提问by Seba Illingworth
The default git diff behavior is to open each diff file in serial (wait for previous file to be closed before opening next file).
默认的 git diff 行为是依次打开每个 diff 文件(在打开下一个文件之前等待前一个文件关闭)。
I'm looking for a way to open all the files at once - in BeyondCompare for example this would open all the files in tabs within the same BC window.
我正在寻找一种同时打开所有文件的方法 - 例如在 BeyondCompare 中,这将在同一 BC 窗口内的选项卡中打开所有文件。
This would make it easier to review a complex set of changes; flick back and forwards between the diff files and ignore unimportant files.
这将使一组复杂的更改变得更加容易;在 diff 文件之间来回滑动并忽略不重要的文件。
采纳答案by Seba Illingworth
Here's what I settled on...
这是我确定的...
Copy the following code to a file called git-diffall
(no extension):
将以下代码复制到名为git-diffall
(无扩展名)的文件中:
#!/bin/sh
git diff --name-only "$@" | while read filename; do
git difftool "$@" --no-prompt "$filename" &
done
Place the file in the cmd
folder of your git install dir (eg C:\Program Files (x86)\Git\cmd
)
将文件放在cmd
git install 目录的文件夹中(例如C:\Program Files (x86)\Git\cmd
)
And use like you would git diff
:
并像您一样使用git diff
:
git diffall
git diffall HEAD
git diffall --cached
git diffall rev1..rev2
etc...
Notes: The key to it is the ¶m which tells the external diff command to run in a background task so files are processed immediately. In the case of BeyondCompare this opens one screen with each file in its own tab.
注意:它的关键是&参数,它告诉外部 diff 命令在后台任务中运行,以便立即处理文件。在 BeyondCompare 的情况下,这会打开一个屏幕,每个文件都位于其自己的选项卡中。
回答by Tim Henigan
Starting with git
v1.7.11, you can use git difftool --dir-diff
to perform a directory diff.
从git
v1.7.11开始,您可以使用git difftool --dir-diff
来执行目录差异。
This feature works well with Meld 3.14.2 for example, and lets you browse all modified files:
例如,此功能适用于 Meld 3.14.2,可让您浏览所有修改过的文件:
git difftool --dir-diff --tool=meld HEAD~ HEAD
This is a handy Bash function:
这是一个方便的 Bash 函数:
git-diff-meld() (
git difftool --dir-diff --tool=meld "${1:-HEAD~}" "${2:-HEAD}"
)
The answer that follows applies to git
installations older than v1.7.11.
下面的答案适用git
于 v1.7.11 之前的安装。
This same question was asked on the git mail list.
在git mail list上也有人问过同样的问题。
I put together a shell script based on that email thread which performs a directory diff between arbitrary commits.
我将基于该电子邮件线程的 shell 脚本放在一起,该脚本在任意提交之间执行目录差异。
Starting with git v1.7.10, the git-diffall
script is included in the contrib
of the standard git installation.
从 git v1.7.10 开始,该git-diffall
脚本包含在contrib
标准 git 安装中。
For versions before v1.7.10, you can install from the git-diffall
project on GitHub.
v1.7.10 之前的版本,可以从GitHub 上的git-diffall
项目安装。
Here is the project description:
这是项目描述:
The git-diffall script provides a directory based diff mechanism for git. The script relies on the diff.tool configuration option to determine what diff viewer is used.
This script is compatible with all the forms used to specify a range of revisions to diff:
1)
git diffall
: shows diff between working tree and staged changes
2)git diffall --cached [<commit>]
: shows diff between staged changes andHEAD
(or other named commit)
3)git diffall <commit>
: shows diff between working tree and named commit
4)git diffall <commit> <commit>
: show diff between two named commits
5)git diffall <commit>..<commit>
: same as above
6)git diffall <commit>...<commit>
: show the changes on the branch containing and up to the second , starting at a common ancestor of both<commit>
Note: all forms take an optional path limiter
[--] [<path>]
This script is based on an example provided by Thomas Rast on the Git list.
git-diffall 脚本为 git 提供了一个基于目录的 diff 机制。该脚本依赖于 diff.tool 配置选项来确定使用的差异查看器。
此脚本与用于指定 diff 修订范围的所有形式兼容:
1)
git diffall
:显示工作树和暂存更改之间的差异
2)git diffall --cached [<commit>]
:显示暂存更改和HEAD
(或其他命名提交)之间的差异
3)git diffall <commit>
:显示工作树和命名提交之间的差异
4)git diffall <commit> <commit>
:显示两个命名提交之间的差异
5)git diffall <commit>..<commit>
:相同如上
6)git diffall <commit>...<commit>
: 显示包含和直到第二个的分支上的变化,从两者的共同祖先开始<commit>
注意:所有形式都采用可选的路径限制器
[--] [<path>]
此脚本基于Thomas Rast 在 Git 列表中提供的示例。
回答by Tom
meld
has a neat feature that if you give it a directory under source control (Git, Mercurial, Subversion, Bazaar and probably others) it will automatically list all the changed files and you can double-click to view the individual differences.
meld
有一个很好的功能,如果你给它一个受源代码控制的目录(Git、Mercurial、Subversion、Bazaar 和其他可能的),它会自动列出所有更改的文件,你可以双击查看个体差异。
IMO it's much easier to type meld .
and have it figure out the VCS than configure your VCS to launch meld
. Plus you can use the same command no matter what VCS your project happens to be using, which is great if you switch between them a lot.
IMO 键入meld .
并让它找出 VCS 比将 VCS 配置为启动要容易得多meld
。此外,无论您的项目碰巧使用什么 VCS,您都可以使用相同的命令,如果您在它们之间切换很多,这非常棒。
The only downside is it is slower for meld to scan for changes than to be passed the changes from git/hg/svn, though whether it's slow enough to be a problem will depend on how you're using it I'm sure.
唯一的缺点是 meld 扫描更改比从 git/hg/svn 传递更改要慢,尽管它是否足够慢以致成为问题将取决于您如何使用它,我敢肯定。
回答by Khaja Minhajuddin
git meld
=> https://github.com/wmanley/git-meldis an awesome script which will open a neat diff of all the files in a single window.
git meld
=> https://github.com/wmanley/git-meld是一个很棒的脚本,它将在一个窗口中打开所有文件的整洁差异。
回答by Seba Illingworth
I did find this method(GitDiff.bat and GitDiff.rb) that copies the files out to old/new temp dirs and then does a folder compare on them.
我确实找到了这种方法(GitDiff.bat 和 GitDiff.rb),它将文件复制到旧/新临时目录,然后对它们进行文件夹比较。
But I'd rather view the working files directly (from the working dir), as BeyondCompare has the handy feature of being able to edit the file from within the diff window which is great for quick cleanups.
但我宁愿直接(从工作目录)查看工作文件,因为 BeyondCompare 具有能够从差异窗口内编辑文件的方便功能,这对于快速清理非常有用。
Edit: a similar method herein response to my question on the git mailing list.
回答by Seba Illingworth
Noticed herethat Araxis Merge has a '-nowait' command option:
这里注意到Araxis Merge 有一个“-nowait”命令选项:
-nowait Prevents compare from waiting for a comparison to be closed
-nowait 防止比较等待比较关闭
Maybe this returns an immediate exit code and would work, anyone experienced this? Can't find similar option for BeyondCompare...
也许这会返回一个立即退出代码并且可以工作,有人遇到过吗?找不到 BeyondCompare 的类似选项...
回答by krlmlr
Diffusealso has VCS integration. It interoperates with a plethora of other VCS, including SVN, Mercurial, Bazaar, ... For Git, it will even show three panes if some but not all changes are staged. In the case of conflicts, there will even be four panes.
Diffuse还集成了 VCS。它可以与大量其他 VCS 互操作,包括 SVN、Mercurial、Bazaar ……对于 Git,如果一些但不是所有更改都已上演,它甚至会显示三个窗格。在发生冲突的情况下,甚至会有四个窗格。
Invoke it with
调用它
diffuse -m
in your Git working copy.
在您的 Git 工作副本中。
If you ask me, the best visual differ I've seen for a decade. (And I've tried meld, too.)
如果你问我,这是我十年来见过的最好的视觉效果。(我也试过融合。)
回答by feltspar
The following works with meld and kdiff3
以下适用于 meld 和 kdiff3
git difftool --dir-diff origin/branch1..origin/branch2
Opens all the files in a window that you can browse with ease. Can be used with changesets in place of origin/branch-name
在您可以轻松浏览的窗口中打开所有文件。可以与变更集一起使用来代替原点/分支名称
eg: git difftool --dir-diff origin/master..24604fb72f7e16ed44115fbd88b447779cc74bb1
例如: git difftool --dir-diff origin/master..24604fb72f7e16ed44115fbd88b447779cc74bb1
回答by sorens
For those interested in using git-diffall on Mac OS X with Araxis, I forked the git-diffall project on github and added an AppleScript that wraps the Araxis Merge command. Note: this is a slightly modified clone of the araxisgitdiff
file that ships with Araxis Merge for Mac OS X.
对于那些有兴趣在 Mac OS X 和 Araxis 上使用 git-diffall 的人,我分叉了 github 上的 git-diffall 项目,并添加了一个包含 Araxis Merge 命令的 AppleScript。注意:这是araxisgitdiff
对 Mac OS X 的 Araxis Merge 附带的文件的稍微修改的克隆。
回答by William Pursell
If all you want to do is open all the files that are currently modified, try something like:
如果您只想打开当前修改的所有文件,请尝试以下操作:
vi $(git status | sed -n '/.*modified: */s///p')
If you are making commits of "complex sets of changes", you might want to reconsider your workflow. One of the really nice features of git is that it makes it easy for the developer to reduce complex change sets to a series of simple patches. Rather than trying to edit all of the files that are currently modified, you might want to look into
如果您要提交“复杂的更改集”,您可能需要重新考虑您的工作流程。git 的一个非常好的特性是它使开发人员可以轻松地将复杂的更改集减少为一系列简单的补丁。与其尝试编辑当前已修改的所有文件,不如查看
git add --patch这将允许您有选择地上演帅哥。