Getting the last commit date from a remote repo without cloning

Viewed 257

I want to get the last commit date in a remote repo without cloning it. Is there a way to do this ? I found several methods but for all of them to work, I need to clone the repo first and then issue the commands to get the last commit date.

Is there a way I can get the last commit date from a remote git without cloning it ?

1 Answers

If it's remote, it's on another server. This means you will need to connect to it somehow, whatever the solution. A usual solution is to just SSH:

ssh remote.server /bin/bash -c 'cd /path/to/remote/repo && git log --all -1 --format=%cd'

Some usual production UIs have rest APIs you can use etc. For Github for example, you can fetch the latest commit object with

https://api.github.com/repos/<user name>/<repo>/commits/<brancH>

(This is based on How can I get last commit from GitHub API) and parse the Json (or Yaml I don't know what they have now, Json seems enough) - under auther and commiter there are dates. If you don't know which branch has the latest commit you have to check them all.

Related