Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the last commit ID of a remote repo using curl-like command?

Tags:

git

git-commit

I want to get the last commit ID of the remote git repo.

The command git rev-parse HEAD works for a locally-cloned git repo, but I want to get it from the original GIT repo by a CURL command or so.

Eg: I want to get the last commit ID of the git URL https://git.appfactorypreview.wso2.com/history/apiapp.git/.

How?

like image 342
Manisha Eleperuma Avatar asked Oct 04 '13 08:10

Manisha Eleperuma


People also ask

How do I find the last commit ID?

To find a git commit id (or hash), you can simply use the git log command. This would show you the commit history, listing the commits in chronological order, with the latest commit first.

Which command will you use to find a commit ID in git?

Just FYI: git log | head -1 is as same as git log | head -n 1 . Although the OP has only asked for the commit ID of HEAD, git log -1 is very useful. Because it also displays the commit message and other details which makes further analysis/comparison easy.


1 Answers

try this command

git log --format="%H" -n 1 
like image 156
Litmus Avatar answered Sep 29 '22 02:09

Litmus