How to get latest git commit id git log -n 1 --pretty=format:'%h' git log -n 1 --pretty=format:'%H' %h for abbreviated commit hash %h for commit hash git log | grep commit | head -1 | awk '{print $2}' git rev-parse HEAD