Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Find current git commit id/hash
$ git log -1 | grep ^commit | cut -d " " -f 2
$ git log -1 | grep ^commit | awk '{print $2}'
Copy link

e3eli3h commented May 23, 2014

$ git log -1 --pretty=format:"%H"

Works well too.

Copy link

hipyhop commented Jul 18, 2019

git rev-parse HEAD

Copy link

stamepicmorg commented Feb 4, 2021

git rev-parse --short=11 HEAD

where 11 is a number of symbols from hash to show

Copy link

lijasonvip commented Jul 23, 2021

it helps a lot, thank you all

Copy link

sunwire commented Aug 1, 2021

git log --branches -1 --pretty=format:"%H"

Copy link

LEUNGUU commented May 6, 2022

Thanks. It helps!

Copy link

Penggeor commented May 7, 2022

git rev-parse HEAD


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment