有 git merge 的 gui (w squash)吗?

发布于 2024-12-08 18:54:24 字数 1432 浏览 0 评论 0 原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

倾其所爱 2024-12-15 18:54:24

Sourcetree 适用于 Windows 和 Mac 的免费 G​​it GUI 支持此

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

 git rebase --interactive --autosquash

因为您使用提交消息进行了提交开始于!squash(当这些中间提交大约是同一任务时)
请参阅“修剪 GIT 签入/压缩 GIT 历史记录”。

The Sourcetree free Git GUI for Windows and Mac supports this.

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

 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".

爱给你人给你 2024-12-15 18:54:24

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

首先,我们想要的“diff”命令:显示“mybranch”上每次提交引入的累积差异,因为它与“master”不同,使用:

git diff master...mybranch

git diff master...HEAD

注意,这不包括同时在 master 上发生的任何提交,这可能是如果您正在审查我的分支,您会想要的。

如果 mybranch 是您当前的头,那么这可以缩写:

git diff master...

Git 将使用“git difftool”将 diff 命令的输出输入到大约八个已知 GUI 工具的列表中之一。我在 OSX 上使用 kdiff3,过去我也在 Linux 上愉快地使用它。我更喜欢 kdiff3,因为它允许我在需要时进行 3 路合并,并且它允许我手动编辑合并的输出以及仅选择要使用的块。

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

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

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

git config --global merge.tool kdiff3

然后在其中查看你的 diff:

git difftool master...

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

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

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.

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

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.

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

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 config --global merge.tool kdiff3

Then view your diffs in it:

git difftool master...
扮仙女 2024-12-15 18:54:24

在 Linux 上,我最喜欢的两个 git GUI 是 gitg融合。要在您的情况下获得正确的代码审查差异,请启动 gitg 并在 master 中找到您合并的最新提交(重要的是,您不希望与 master 的当前头进行比较,以防 master 自上次合并以来已高级) )。复制此 SHA1 并将其放入您的 git difftool 中:

git difftool -t meld <SHA1>

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

git config --global diff.tool meld

On Linux, my two favourite GUIs for git are gitg and 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:

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:

git config --global diff.tool meld
最佳男配角 2024-12-15 18:54:24

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

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

这将显示两个分支之间的差异。然而,我知道 git 和任何 git GUI 都不支持压缩提交,恕我直言,这太糟糕了。

所以我最终做了一个

git rebase --interactive HEAD~3 

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

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

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.

So I end up doing a

git rebase --interactive HEAD~3 

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文