任何用于 git merge (w 壁球) 的 gui?

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

Any gui for git merge (w squash)?

gituser-interfacemergebranchsquash

提问by Tom Fishman

My work flow:

我的工作流程:

  • branch from master
  • work in my branch, commit frequently (100+)
  • when the job is done in my branch, merge master into my branch, resolve all the conflict.
  • CODE REVIEW TIME before merging back to master
  • 从主分支
  • 在我的分支工作,经常提交(100+)
  • 在我的分支中完成工作后,将 master 合并到我的分支中,解决所有冲突。
  • 合并回母版之前的代码时间

For CODE REVIEW, I need to show the differencesbetween two heads and squash/organize my commits( in about 5 commits ). What's the best GUI (cross-platform?) for this task?

对于代码,我需要显示两个头之间的差异压缩/组织我的提交(大约 5 次提交)。此任务的最佳 GUI(跨平台?)是什么?

采纳答案by VonC

The Sourcetreefree Git GUI for Windows and Mac supports this.

适用于 Windows 和 Mac的Sourcetree免费 Git GUI支持此.

Alternatively, to do it without a GUI, you can run

或者,要在没有 GUI 的情况下执行此操作,您可以运行

 git rebase --interactive --autosquash

because you committed with commit message beginning with !squash (when those intermediate commits were about the same task)
See "Trimming GIT Checkins/Squashing GIT History".

因为您提交了以 !squash 开头的提交消息(当这些中间提交是关于相同的任务时)
请参阅“修剪 GIT 签入/压缩 GIT 历史记录”。

回答by Jonathan Hartley

The output of any 'git diff' command can be displayed in a GUI tool using the 'git difftool' command.

任何“git diff”命令的输出都可以使用“git difftool”命令显示在 GUI 工具中。

Firstly, the 'diff' command we want: Display the accumulated diffs introduced by every commit on 'mybranch' since it diverged from 'master' using:

首先,我们想要的 'diff' 命令:显示由 'mybranch' 上的每次提交引入的累积差异,因为它使用:

git diff master...mybranch

or

或者

git diff master...HEAD

Note this excludes any commits that have happened on master in the meantime, which is probably what you want if you are reviewing mybranch.

请注意,这不包括在此期间在 master 上发生的任何提交,如果您正在查看 mybranch,这可能是您想要的。

If mybranch is your current head, then this can be abbreviated:

如果 mybranch 是您当前的负责人,那么这可以缩写为:

git diff master...

Git will feed the output from diff commands into one of a list of about eight known GUI tools, using 'git difftool'. I use kdiff3 on OSX, and in the past I've used it happily on Linux too. I prefer kdiff3 because it lets me do 3-way merges when required, and it lets me edit the output of the merge manually as well as just selecting hunks to use.

Git 将使用 'git difftool' 将 diff 命令的输出提供给大约八个已知 GUI 工具的列表之一。我在 OSX 上使用 kdiff3,过去我也很高兴在 Linux 上使用它。我更喜欢 kdiff3,因为它允许我在需要时进行 3 向合并,并且它允许我手动编辑合并的输出以及只选择要使用的大块。

First install kdiff3, then add a symlink to it on your PATH. For me, that was:

首先安装 kdiff3,然后在你的 PATH 上添加一个符号链接。对我来说,那是:

ln -s /Applications/kdiff3.app/Contents/MacOS/kdiff3 /usr/local/bin/kdiff3

Then tell git that you want to use kdiff3 as your GUI diff tool:

然后告诉 git 你想使用 kdiff3 作为你的 GUI diff 工具:

git config --global merge.tool kdiff3

Then view your diffs in it:

然后在其中查看您的差异:

git difftool master...

回答by exclipy

On Linux, my two favourite GUIs for git are gitgand meld. To get the correct diff for code review in your case, launch gitg and find the latest commit in master that you merged from (importantly, you don't want to diff against the current head of master in case master has advanced since you last merged). Copy this SHA1 and put it into your git difftool:

在Linux上,我的两个GIT中最喜欢的图形用户界面是gitgMELD。要在您的案例中获得正确的代码差异,请启动 gitg 并找到您从中合并的 master 中的最新提交(重要的是,您不想与当前的 master 负责人进行比较,以防 master 自上次合并以来已经进步)。复制此 SHA1 并将其放入您的git difftool

git difftool -t meld <SHA1>

To set it up so you don't have to specify meld as the difftool every time, just set it in the config:

要设置它以便您不必每次都将 meld 指定为 difftool,只需在配置中设置它:

git config --global diff.tool meld

回答by RaB

Eclipse can do the comparison part. You can right click on the project and select

Eclipse 可以做比较部分。您可以右键单击项目并选择

Team->Advanced->Synchronize With...->(branch you want to compare against)

That shows you the diff between the 2 branches. However, neither git nor any git GUI I know supports squashing commits which IMHO is too bad.

这向您展示了 2 个分支之间的差异。但是,无论是 git 还是我所知道的任何 git GUI 都不支持压缩提交,恕我直言太糟糕了。

So I end up doing a

所以我最终做了一个

git rebase --interactive HEAD~3 

(in case I had 3 commits I want to squash).

(如果我有 3 个提交,我想压缩)。