Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to "git show" on a remote repo?

Tags:

git

I'm trying to hook my git repository with Microsoft's Source Server feature such that people debugging into my binary will automatically pull source files down from github.com.

The git show command will get me the right file and version that I need, but since the debugger is not running on a computer with a local git repo of the project source code, I need "git show" to pull from github instead of a local directory. I'm imagining something like this:

git --no-pager "--git-dir=git://github.com/AArnott/dotnetopenid.git" show 93e76d5ff529b6c9921a984c3608c150ed4ee7a3

When the --git-dir argument is a local directory this works fine, but when it's a remote location it gives me an error such as:

fatal: Not a git repository: 'git://github.com/AArnott/dotnetopenid.git'

What git command will pull down a particular version of a particular file from a remote URL location?

like image 250
Andrew Arnott Avatar asked Feb 27 '23 20:02

Andrew Arnott


1 Answers

Unfortunately git does not support fetching individual remote files. There are three workarounds:

  • Use git fetch to get the remote history, then snatch the file from the local object store.
  • Use git archive to get a complete tree (e.g. git archive --remote=url master:somesubdir) in tar format on stdin.
  • Setup gitweb or something like that on the server and get the file through that.
like image 123
Jan Krüger Avatar answered Mar 18 '23 23:03

Jan Krüger