How to display git shortsha in terminal
Article originally published here : https://alsohelp.com/blog/how-to-display-git-shortsha-in-terminal I had a problem displaying the image here on dev.to, everywhere else, the text is fine Article below : The answer The answer is already given in this StackOverflow answer more than 6 years ago (!) and still holds true nowadays : git rev-parse --short HEAD # 4d7b213 Why the short sha? In Git every commit is identified by a 40-character hexadecimal string named the "Git SHA". See the commit number pointer by the arrow ? (view it in original article) Yes, that's the git short SHA. Only the first 7 digits amongst the 40. The risk of collision is small enough to identify uniquely each commit. Trick to display the short SHA in the Terminal You can define an alias, on Linux or Windows, in order to display it without to remember the whole command : alias shortsha='git rev-parse --short HEAD' (exemple from my Linux machine) Will be used like this : shortsha # 4d7b213 Neat! Last trick Sometimes, you will try some attempt to display it somewhere in the footer, in order to increase confidence about which version of the website is deployed. I like and use it, but I admit it's not very common though. Summary That was a quick recap about the git short SHA.

Article originally published here : https://alsohelp.com/blog/how-to-display-git-shortsha-in-terminal
I had a problem displaying the image here on dev.to, everywhere else, the text is fine
Article below :
The answer
The answer is already given in this StackOverflow answer more than 6 years ago (!) and still holds true nowadays :
git rev-parse --short HEAD
# 4d7b213
Why the short sha?
In Git every commit is identified by a 40-character hexadecimal string named the "Git SHA".
See the commit number pointer by the arrow ? (view it in original article)
Yes, that's the git short SHA.
Only the first 7 digits amongst the 40.
The risk of collision is small enough to identify uniquely each commit.
Trick to display the short SHA in the Terminal
You can define an alias, on Linux or Windows, in order to display it without to remember the whole command :
alias shortsha='git rev-parse --short HEAD'
(exemple from my Linux machine)
Will be used like this :
shortsha
# 4d7b213
Neat!
Last trick
Sometimes, you will try some attempt to display it somewhere in the footer, in order to increase confidence about which version of the website is deployed. I like and use it, but I admit it's not very common though.
Summary
That was a quick recap about the git short SHA.