4

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?

Andrew Arnott
  • 80,040
  • 26
  • 132
  • 171
  • "It looks like at best I need at least two commands": two commands that could be bundled into *one* script, no? And even git aliased. – VonC Dec 29 '09 at 09:18
  • No script files can be assumed to exist on the customer's debugging machine. So the command must be completely self-contained, relying only on a command interpreter that the customer must already have. That said, I considered a PowerShell command, since that can be a large script all on one command-line. But so far I've been unsuccessful at figuring out how to do a shallow clone, or a fetch of exactly one version of a remote repo. – Andrew Arnott Dec 30 '09 at 18:26
  • Couldn't you use curl or wget to download those files from your github repo? – jj. Sep 14 '17 at 18:02
  • @jj. Only if the git host offered http to serve raw files and I could predict the URL. No way exists to do that and some hosts don't offer raw content over http anyway. – Andrew Arnott Sep 14 '17 at 19:33

2 Answers2

7

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.
Jan Krüger
  • 17,870
  • 3
  • 59
  • 51
1

If you are installing binaries on a system, and are expecting people to be "debugging into your binary", it seems you could install a few extra files, no?

One of those could be a $HOME/.gitconfig (or whatever it is called on windows) that has aliases in it, something like:

[remote "msrepo"]
   url = http://microsoft/git/url.git
[alias]
   msreposhow "git fetch --no-pager msrepo; git show $1"

Then you could do a "git msreposhow SHAKEY" in one step, which will call the alias and execute both commands in one step.

qneill
  • 1,643
  • 14
  • 18
  • "git remoteshow" isn't a valid command (on 1.7.3.1.msysgit.0 anyway). Is this a typo, or a command I'm missing? – Andrew Arnott Feb 22 '11 at 18:37
  • 1
    It was a typo, sorry, StackNewbieUnderFlow. It was supposed to show a call to the alias defined in the code. I fixed the post and reformatted. – qneill Mar 03 '11 at 20:02