1

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.

Neman
  • 157
  • 1
  • 11

1 Answers1

1

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.

SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
  • Yes of course. But why you need a build-in GUI tool from Git? There are multiple other third-party tools, where you can locate the *short* commit hash fast and easy. As example [Git-Fork](https://git-fork.com/). I like this git-client. But there are also other powerful git-clients, where you can help to find easy the *short* commit hash. – SwissCodeMen Jul 16 '21 at 22:33
  • Thank you @SwissCodeMen. Disappointing - I was led to believe Git could do anything at all. :-D As far as I can tell, this affects the text copied when you use the Copy Commit Reference, which is the commit hash and the commit message itself. So as a workaround, it creates its own work (since you now have to delete the commit message after pasting), but it at least removes the annoyance of manually selecting the first 7. Observation: When the length is set to 40, I always get 7 characters. When the length is NOT 40, I get that number of characters. – Neman Jul 17 '21 at 02:20
  • True, but I am hoping to keep as lightweight as possible until I actually understand what Git is doing and focusing on the command line as my path. But sometimes I just need a visualizer. :-) Thanks again! – Neman Jul 17 '21 at 02:39
  • @Neman: `gitk` is distributed *with* Git but not maintained by the Git folks. It definitely has some bugs, in some releases. Feel free to maintain it for the Git folks... :-) – torek Jul 18 '21 at 05:06
  • @torek Hahaha! If I knew what I was doing, I'd be doing that. :-D Really good to know though - I had totally assumed Gitk was part of/maintained by the SCM Git team. I'll have to learn how to make a suggestion for Gitk. – Neman Jul 19 '21 at 14:08