Home > database >  Git diff-tree always print full commit hash
Git diff-tree always print full commit hash

Time:07-04

I'd like to get the abbreviated commit hash of HEAD using diff-tree, but I've tried all the following, all of which output a full commit hash:

git diff-tree --no-patch --abbrev-commit HEAD
git diff-tree --no-patch --abbrev=10 HEAD
git diff-tree --no-patch --format=%h HEAD
git diff-tree --no-patch --pretty=format:%h HEAD

I've switched to git rev-parse --short --verify HEAD to get what I expected, but I wonder why diff-tree just won't give me an abbreviated commit hash?

CodePudding user response:

I'm not sure 100% why the format is ignored, probably it's mentioned somewhere in the docs. But after looking in the diff-tree docs and especially the --abbrev-commit part, adding --abbrev=n displays n length hash.

git diff-tree --no-patch --abbrev-commit --abbrev=10 HEAD
  • Related