Get the root commit hash (“initial commit”) in git

The following will get you the initial commit on the current branch, based on the logic that the root has no parents:

git rev-list --max-parents=0 HEAD