1

I would like to checkout a single file from a remote git-repository.

Is there a way to checkout a single file from a remote git-repository, without checking out the other commits?

EDIT:

Following the answers, I've realized that i can do a git fetch, and then a git checkout origin/branch path/to/file, which works great.

Silfverstrom
  • 28,292
  • 6
  • 45
  • 57
  • Related: http://stackoverflow.com/questions/1178389/browse-and-display-files-in-a-git-repo-without-cloning – Josh Lee Sep 23 '10 at 13:34
  • The terminology in your question is confusing - do you want to *fetch* or *checkout* a single file? You can *fetch* from a remote repo without affecting your working tree, then you can *checkout* one particular file into your working tree. – Steve Folly Sep 23 '10 at 13:45

1 Answers1

3

This similar question shows a few solutions, including git show and git cat-file.

git show rev:path/to/file

If you want to retrieve the contents into a file, you'll need redirect stdout appropriately.

Community
  • 1
  • 1
Mike Seplowitz
  • 9,785
  • 1
  • 24
  • 23