Git分支目录比较
我最喜欢的 svn 工作流程之一是使用 Beyond Compare 的文件夹比较功能来查看两个分支或分支与主干之间的净差异。有没有办法在 git 中执行此操作,而无需手动创建同一存储库的多个克隆?
当我问这个问题时,我突然想到我可以编写一个脚本,将当前存储库克隆到临时目录,签出所需的分支,然后使用两个目录作为参数调用 BCompare.exe。文件夹比较视图通过
BCompare.exe path/to/folder1 path/to/folder2
这听起来合理吗?使用 Beyond Compare 后我可以删除多余的克隆吗?
One of my favorite workflows with svn is to use Beyond Compare's folder comparison feature to see the net differences between two branches, or a branch and the trunk. Is there a way to do this in git without having to manually create multiple clones of the same repository?
As I ask this question, it occurs to me that I could write a script that would clone the current repo to a temporary directory, checkout the desired branch, and then call BCompare.exe with the two directories as arguments. The folder comparison view is invoked with
BCompare.exe path/to/folder1 path/to/folder2
Does this sound reasonable? Would I be able to delete the extra clone after I'm done with Beyond Compare?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这个(比较目录而不是逐个文件)应该很快就会可用:
请参阅[公告] Git 1.7.11.rc1:
请参阅“补丁
difftool
:教difftool
处理目录差异”,来自此 git 分支:This (comparing directories instead of file-by-file) should be available soon:
See [ANNOUNCE] Git 1.7.11.rc1:
See "Patch
difftool
: teachdifftool
to handle directory diffs", from this fork of git:听起来您已经找到了正确的答案 - 使用 git clone 和 git checkout 设置要比较的目录,然后运行 BCompare。 exe.下面的脚本可能是一个很好的起点。
It sounds like you've already figured out the right answer -- use
git clone
andgit checkout
to set up a directory to compare to, then runBCompare.exe
. The below script might be a good starting point.只需使用
git diff
加上要比较的分支的名称或哈希值,就这么简单。实际上,您可以通过哈希值来比较任意两个提交。Just
git diff
with the names or hashes of the branches you want to compare, simple as that. Actually, you can compare any two commits by their hashes.首先验证您是否具有超越比较功能,
您可以使用: git difftool --tool-help 列出可用的比较工具。
(要将其设置为默认值,请参阅 Git Diff 与 Beyond Compare)
如果您有 Beyond Compare你可以使用其中之一:
编辑:适用于 git 版本 2.25
First verify you have beyond compare accessible,
you can use:
git difftool --tool-help
to list the available compare tools.(to set it as default see Git Diff with Beyond Compare)
If you have beyond compare you can use one of those:
EDIT: works in git version 2.25