Reason: I want to compare two arbitrary different commits using a difftool. I know the hashes from a search and I don't want to copy these hashes, thus I am looking for a command that does something like
$ log_str=$(git log --all -S"new_tour <-" --pretty=format:"%h")
$ git difftool -t kdiff3 log_str[1] log_str[2] myfile.txt
- I would like to be able to address arbitrary indices - not always 1 and 2
- It would be great if the answer also gives a hint, how to figure out, what the structure of
log_stris. Is it a character? An array of characters? A list? ... using the Bash.
I found some related help here and here, but I can't make it work.
Now I do:
$ git log --pretty=format:"%h"
3f69dc7
b8242c6
01aa74f
903c5aa
069cfc5
and
$ git difftool -t kdiff3 3f69dc7 b8242c6 myfile.txt
git diff HEAD~1 HEAD? That's the command you currently have. (Which is the same asgit show)git rev-listrather thangit log: it's designed for scripting.git rev-list -S"new_tour <-" --pretty=format:"%h"does not work. Did I miss anything?--allabove; you'll need that, orHEAD, here (this is one significant difference fromgit log, which will assumeHEADif not given other revision specifiers to start from). Remove the--prettyargument entirely: rev-list's main job is to list revision hash IDs, so that's what it does by default.