Search code examples
githashcommitgitk

How to display short form of commit hash in gitk?


This seems like it should be a simple display preference...

I use Gitk to browse a repo and find an interesting commit. The full 40 char commit/SHA1 hash of the current commit appears under the list of commits:

full 40 char commit/SHA1 hash

How do I get the short form, i.e. what git log -n 1 --oneline would generate? I often don't want to put the whole commit hash into for-human communications. It's ugly, and when you inevitably end up in situations where you can't copy/paste, it creates the unnecessary question of how many characters do you read off to guarantee uniqueness. It's also a bit of an odd discussion to have over the telephone. :-)

Edit > Preferences > General > Auto-select SHA1 (length) had no perceivable effect when changing the value from 40 to 10 or by turning off the checkbox:

Preferences dialog showing Auto-select SHA1 (length) option

Knowing the full hash is often of no value to me; all I need is uniqueness, and if the short hash is effectively unique, then I'm happy to not see the full hash in any circumstance that matters to how I use it.


Solution

  • You can't do that.

    You can only with Auto-select SHA1 (length) choose, how many characters should be marked. If you select the checkbox Auto-select SHA1 (length) and write 7 in the textbox behind, the short hash form would be marked. Look at the picture. You can't only display the short hash.

    enter image description here

    Edit > Preferences > General > Auto-select SHA1 (length) had no perceivable effect when changing the value from 40 to 10 or by turning off the checkbox

    According to this sequence, you must click the commit new, that the changes you have made, take effect.