Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git operations on remote repository without local clone

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.

like image 732
MvG Avatar asked Oct 19 '22 20:10

MvG


1 Answers

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:

  • since git 1.70 you can clone a single branch
  • since git 2.5 (mid 2015), you can fetch a single commit(!) without cloning the full repo.
like image 78
VonC Avatar answered Oct 22 '22 22:10

VonC