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?
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.
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.
try this command
git log --format="%H" -n 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With