5

What kind of read-only operations are possible on a remote git repository using the standard git command line tool without having a local clone?

  • Is there some way to list refs (in particular tags and branches) on the remote repo?
  • Is there a way to list the content of a given directory in a given revision?
  • Is it possible to retrieve the content of a given file at a given revision?

I guess that doing this without a local clone might involve some low level primitive operations, and I guess that making this usable might best be accomplished by some short shell script. That would still be within the scope of this question.

MvG
  • 57,380
  • 22
  • 148
  • 276
  • possible duplicate of [Git: getting info about a change without a local repository?](http://stackoverflow.com/questions/4994004/git-getting-info-about-a-change-without-a-local-repository) – Jørgen R Dec 12 '14 at 12:21
  • Points 2 and 3 depend - where do you host your repos? GitHub and Visual Studio Online offer some information via REST APIs. If you use ssh to access your repo then you may be able to run some commands. Etc. – Edward Thomson Dec 12 '14 at 12:42
  • @EdwardThomson: for my question here I was interesting in what the git tools offer by themselves. For the case where I asked this question, it was a private gitolite server with not accompanying gitweb. – MvG Dec 12 '14 at 12:49

1 Answers1

3

Is there some way to list refs (in particular tags and branches) on the remote repo?

Yes, that is what git ls-remote does.

Is there a way to list the content of a given directory in a given revision?
Is it possible to retrieve the content of a given file at a given revision?

2012: However, beside getting branches and tags, I don't think you can get the content without cloning (full clone or sparse checkout or shallow clone).
And you cannot do a shallow clone for a specific commit or tag, or for a specific branch.

Update 2016:

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • You've already updated your linked answer to mention git 1.7.10's `--single-branch` clone option, so I'll just put that in this comment here. (Stumbled over this old answer while following links. :-) ) – torek Apr 03 '16 at 19:02
  • @torek Thank you. I have updated the answer accordingly. And I have added that you actually can fetch a single commit (without cloning the full repo) – VonC Apr 03 '16 at 19:08