How can I check with the command line the latest commit hash of a particular Git branch?
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