Question

I want to append the hash of the ongoing commit to its result. I can retrieve the hash using this command:

git log --format=%H | tail -1

Then I try to merge a commit with command above and make an alias in '.gitconfig', like this:

[alias]
    ci = !git commit && git log --format=%H | tail -1

But this does not work; parameters of alias are send to tail command, not git commit.
How should I create this alias?

Was it helpful?

Solution

ci = !sh -c 'git commit "$@" && git log --format=%H | tail -1' --

You can find more info here

Also this is a more optimal way to get the hash of the last commit:

git log -1 --pretty=format:%H
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top