Jeenu
Jeenu

Reputation: 2231

Is there a way how commit IDs relative to HEAD?

I was wondering if there's a way to list commit IDs as relative to HEAD, instead of SHA1 sum, with git log. For example, as @~1, @~2, @^2 and so forth? Not that it's a big deal figuring this out manually, but it'd be nifty if git already displays this.

Upvotes: 1

Views: 95

Answers (1)

VonC
VonC

Reputation: 1324347

There was a tweet this morning mentioning list offsets from HEAD with git log

git log --oneline | nl -v0 | sed 's/^ \+/&HEAD~/'
# or
o=0; git log --oneline | while read l; do printf "%+9s %s\n" "HEAD~${o}" "$l"; o=$(($o+1)); done | less

Basically, there is no native way of "decorating" a git log with that particular format.
You are left with bash to transform the output.

Upvotes: 1

Related Questions