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".
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:
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:
发布评论
评论(4)
Sourcetree 适用于 Windows 和 Mac 的免费 Git GUI 支持此。
或者,要在没有 GUI 的情况下执行此操作,您可以运行,
因为您使用提交消息进行了提交开始于!squash(当这些中间提交大约是同一任务时)
请参阅“修剪 GIT 签入/压缩 GIT 历史记录”。
The Sourcetree free Git GUI for Windows and Mac supports this.
Alternatively, to do it without a GUI, you can run
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".
任何“git diff”命令的输出都可以使用“git difftool”命令显示在 GUI 工具中。
首先,我们想要的“diff”命令:显示“mybranch”上每次提交引入的累积差异,因为它与“master”不同,使用:
或
注意,这不包括同时在 master 上发生的任何提交,这可能是如果您正在审查我的分支,您会想要的。
如果 mybranch 是您当前的头,那么这可以缩写:
Git 将使用“git difftool”将 diff 命令的输出输入到大约八个已知 GUI 工具的列表中之一。我在 OSX 上使用 kdiff3,过去我也在 Linux 上愉快地使用它。我更喜欢 kdiff3,因为它允许我在需要时进行 3 路合并,并且它允许我手动编辑合并的输出以及仅选择要使用的块。
首先安装 kdiff3,然后在 PATH 中添加一个符号链接。对我来说,那就是:
然后告诉 git 你想使用 kdiff3 作为你的 GUI diff 工具:
然后在其中查看你的 diff:
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:
or
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 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:
Then tell git that you want to use kdiff3 as your GUI diff tool:
Then view your diffs in it:
在 Linux 上,我最喜欢的两个 git GUI 是 gitg 和 融合。要在您的情况下获得正确的代码审查差异,请启动 gitg 并在 master 中找到您合并的最新提交(重要的是,您不希望与 master 的当前头进行比较,以防 master 自上次合并以来已高级) )。复制此 SHA1 并将其放入您的 git difftool 中:
要进行设置,以便您不必每次都将 meld 指定为 difftool,只需在配置中设置它:
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
:To set it up so you don't have to specify meld as the difftool every time, just set it in the config:
Eclipse可以做比较部分。您可以右键单击该项目并选择
这将显示两个分支之间的差异。然而,我知道 git 和任何 git GUI 都不支持压缩提交,恕我直言,这太糟糕了。
所以我最终做了一个
(如果我有 3 个提交,我想压缩)。
Eclipse can do the comparison part. You can right click on the project and select
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
(in case I had 3 commits I want to squash).