question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Most efficient way to fetch a single file from a given revision or branch?

See original GitHub issue

Suppose I have a Git URL + revision and I want to fetch the README.md file, if present.

My current solution is to:

  • Create a temporary folder
  • Git clone from the URL into the folder
  • Git checkout the revision, branch or tag
  • Read
  • Clean-up the folder

This works, but is it the best approach using isomorphic-git?

I believe that the git CLI tool can do this efficiently using git archive.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
wmhiltoncommented, May 25, 2018

I should add an option to checkout to check out a specific filepath. That would save a lot of disk thrashing.

0reactions
wmhiltoncommented, Jun 4, 2018

it might make sense to add an option to skip the checkout step at the end of a normal clone.

FYI I have added a noCheckout parameter to clone in #240.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to retrieve a single file from a specific revision in Git?
Using git show. To complete your own answer, the syntax is indeed git show object git show $REV:$FILE git show ...
Read more >
Git Checkout – How to Checkout a File from Another Branch
Solution 1: Use the git checkout command · A folder from another branch. · Multiple files by specifying each one of them.
Read more >
get a file from a specific revision - Git Ready
Probably the best use of this command is to see what the file looked like and perhaps write its contents out to a...
Read more >
git-fetch Documentation - Git
Fetch branches and/or tags (collectively, "refs") from one or more other repositories, along with the objects necessary to complete their histories.
Read more >
Checkout a specific revision with Git - SysGears
Checkout a specific revision with Git · 1) Clone the project: 1 2 · 2) Use the git describe command to get readable...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found