git: get short hash of remote repo
Atm I'm maintaining my urho3d-minimal-new-project to use the latest version of urho3d in its docker-images. To make this a smoother 'one-click' process I want the new docker-images to have an additional flag like 'githash-$HASH' where the $HASH is the current short-version of the urho3d's git-HEAD. Based on this stackoverflow post:
git ls-remote https://github.com/urho3d/Urho3D.git HEAD | awk '{ print substr($1,1,10) }'
This will get the first 10 chars of the long-hash. That should be enough. Be aware that the uniqueness of the short-hash depends on the size of the project. Here some hint this git doc:
Generally, eight to ten characters are more than enough to be unique within a project. For example, as of February 2019, the Linux kernel (which is a fairly sizable project) has over 875,000 commits and almost seven million objects in its object database, with no two objects whose SHA-1s are identical in the first 12 characters.