gitk Notes

Russell Bateman
March 2014
last update:

Install gitk, the Git repository browser. (The representation at the right is only a vague illustration whose details do not figure in this document.) If missing (and it probably is), you'll need to install gitk.

$ apt-get install gitk
$ gitk --all &

The upper left-pane of gitk is a very busy GUI browser with lots going on that will take a little while to figure out. Note that yellow marks where you're at. Use Ctrl-F5 to refresh if changes happen outside gitk control during a gitk session.

The reason I began to use this tool grew out of a large project where many commits were happening while at the same time I was struggling to manage rather large slices of change work myself with, to boot, the need to justify this work in a change review setting with other engineers. My changes were scaled across multiple commits making the use of git diff or IntelliJ's Diff impractical as not all the changes were visible.

git reset options

You can right-click on certain lines (where it makes sense) to "reset" which moves the current pointer back (down) to make everything already done appear as changes (in git status). That way, we can review changes across server commits as one. Options are:

--soft doesn't wipe out changes
--hard wipes out changes beyond that point

You can locate SHA1 hashes to use as arguments to git reset using

Here are random command lines to contemplate:

$ git remote update
$ git stash
$ git stash pop
$ git branch review
$ git commit fsbe-domain/ -m squash
$ git checkout review
$ git merge master
$ git reset --soft 7687e205a55932aa58c2483b1ff0d3e296545740
$ git reset --soft fcd769d3cd916e603a5852a5a82e62fbbfde5c27

A mode of working

You can commit incrementally, then late do a soft reset to review and "really" do the commit:

Use git rebase --interactive to launch editor and let you "squash" changes into one. Without the interactive option, git will replay everything, but not squash multiple commits.

A good link on the above is: git-rebase(1) Manual Page.

Sample order of work

  1. Edit some files, make changes.
  2. git commit -a
  3. Edit some more files, make changes.
  4. git commit -a
  5. git remote update (or git pull origin master?)
  6. git rebase --interactive origin/master
    1. Replays everything if no conflict.
    2. Opens editor; leave what's in the top alone.
    3. On left side, use s to squash each commit into one.
    4. Exit editor with update.
    5. Editor reopens (under git rebase --interactive control).
    6. Make final commit message.
    7. Exit editor with update.
  7. git push origin master