Most efficient way to fetch a single file from a given revision or branch?
See original GitHub issueSuppose 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:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I should add an option to checkout to check out a specific filepath. That would save a lot of disk thrashing.
FYI I have added a
noCheckout
parameter toclone
in #240.