Skip to content

Instantly share code, notes, and snippets.

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

e3eli3h commented May 23, 2014

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

Works well too.

@hipyhop
Copy link

hipyhop commented Jul 18, 2019

git rev-parse HEAD

@stamepicmorg
Copy link

stamepicmorg commented Feb 4, 2021

git rev-parse --short=11 HEAD

where 11 is a number of symbols from hash to show

@lijasonvip
Copy link

lijasonvip commented Jul 23, 2021

it helps a lot, thank you all

@sunwire
Copy link

sunwire commented Aug 1, 2021

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

@LEUNGUU
Copy link

LEUNGUU commented May 6, 2022

Thanks. It helps!

@Penggeor
Copy link

Penggeor commented May 7, 2022

git rev-parse HEAD

Good

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