It is the commit ID consisting of all zeros.
I added the following line to ~/.config/git/template/hooks/post-checkout
:
echo "post-checkout" "$@" 1>&2
and then cloned a new repository, getting the following output:
post-checkout 0000000000000000000000000000000000000000 4abcac4ddfb69f6dfde1af0164f2f0ee0e230336 1
So it looks like the "null-ref" in the post-checkout
script is 0000000000000000000000000000000000000000
.
The context behind this question is that I want to set a special per-repo Git config user.email
value only when I clone repositories from my work's Gitlab server. Now I can put the following in the post-checkout script to change it:
# This value of `$1` is the null-ref from githooks(5) - see
# https://stackoverflow.com/a/73000183/207384.
# for sed trick see torek's answer
if [[ "$1" = "$(git rev-parse HEAD | sed s/./0/g)" ]]; then
# Set user.email specially for work repositories.
if [[ "$(git config remote."$(git config branch."$(git branch --show-current)".remote)".url)" =~ "gitlab.example.com" ]]; then
git config user.name "John Doe"
git config user.email "John Doe@example.com"
fi
fi