kdt
kdt

Reputation: 28489

Git: getting info about a change without a local repository?

My program has remote access to a git repository over ssh, and sometimes needs to get information (like commit message) about particular git commits. How can I query a remote git repository for this kind of information, without having a local clone of the repository?

Upvotes: 3

Views: 2181

Answers (4)

mahemoff
mahemoff

Reputation: 46399

You can also use the repository host's API, if you are hosting with Github, Bitbucket, or similar.

Upvotes: 0

TigrisC
TigrisC

Reputation: 1360

You could use ssh remote command execution to execute arbitrary git commands

$ssh user@host "cd path/to/repo && git log"

Upvotes: 1

poke
poke

Reputation: 387677

You could probably do this, by emulating a lot of operation git already does internal and by heavy manual usage of the git plumbing (low-level) commands. However if you do that, you not only need to a lot of really low-level things yourself, you also will end up with very little efficiency in what you do (not only if you request information for a second time).

So I would suggest you to just do a (high-level) clone from the repository and work with it that way, even if that repository will only exist temporary. If you only want to look at the newest commits for example, you can easily restrict what you clone by creating a shallow clone (use the --depth option with clone).

Upvotes: 2

Htbaa
Htbaa

Reputation: 2309

I only know of git ls-remote to lookup the available tags and branches and their latest commit id's. You could use that to check if a new commit has been made to a branch.

Upvotes: 5

Related Questions