Skip to content

Instantly share code, notes, and snippets.

@mamchenkov
Last active July 23, 2024 19:41
Show Gist options
  • Select an option

  • Save mamchenkov/930900 to your computer and use it in GitHub Desktop.

Select an option

Save mamchenkov/930900 to your computer and use it in GitHub Desktop.
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

e3eli3h commented May 23, 2014

Copy link
Copy Markdown

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

Works well too.

@hipyhop

hipyhop commented Jul 18, 2019

Copy link
Copy Markdown

git rev-parse HEAD

@stamepicmorg

Copy link
Copy Markdown

git rev-parse --short=11 HEAD

where 11 is a number of symbols from hash to show

@lijasonvip

Copy link
Copy Markdown

it helps a lot, thank you all

@sunwire

sunwire commented Aug 1, 2021

Copy link
Copy Markdown

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

@LEUNGUU

LEUNGUU commented May 6, 2022

Copy link
Copy Markdown

Thanks. It helps!

@wukaipeng-dev

Copy link
Copy Markdown

git rev-parse HEAD

Good

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