Domanda

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

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

È stato utile?

Soluzione

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

Altri suggerimenti

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

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

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top