Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command to get latest Git commit hash from a branch

Tags:

git

github

How can I check with the command line the latest commit hash of a particular Git branch?

like image 374
mbdvg Avatar asked Mar 28 '13 08:03

mbdvg


1 Answers

git log -n 1 [branch_name] 

branch_name (may be remote or local branch) is optional. Without branch_name, it will show the latest commit on the current branch.

For example:

git log -n 1 git log -n 1 origin/master git log -n 1 some_local_branch  git log -n 1 --pretty=format:"%H"  #To get only hash value of commit 
like image 126
Rahul Tapali Avatar answered Oct 13 '22 21:10

Rahul Tapali