Git download a single file from a commit
Do a "git export" like "svn export"? Excluding files from git archive exports using gitattributes. Git - git-archive Documentation. Sorry, something went wrong. As a general rule, if you have a url that works, you can replace "master" with the specific sha you want. How to download a project subdirectory from GitHub Example. Skip to content. Star 1. New issue. Jump to bottom. Add a comment. It should work, except that the web stuff is generated on the fly.
Will: You'll have to handle that response in a script or whatnot, or just paste the link into a browser. It is obtuse, but Git doesn't provide a simple way to grab just one commit. I know this works when you have a clone of the repo or a similar repo.. That will work only if the commit you are cherry-picking is an ancestor of the repo's HEAD. I've just tried this the git fetch tries to download everything. Community Bot 1 1 1 silver badge. Joshua Smith Joshua Smith 6, 1 1 gold badge 27 27 silver badges 27 27 bronze badges.
As correctly stated in Josh Lee answer short answer is not possible. Jorri Fransen Jorri Fransen 21 5 5 bronze badges. I used: git format-patch sha-id Just specify the sha-id which is just older than the required commit. Daenyth Daenyth David David 1 1 1 bronze badge. The question is a bit ambiguous, but "downloading a commit" is usually about download the files in the commit which git show does not do if it gives you just a single file.
I have to downvote this as this answer is plainly wrong. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password.
Post as a guest Name. Email Required, but never shown. The Overflow Blog. Who owns this outage? Building intelligent escalation chains for modern SRE.
Podcast Who is building clouds for the independent developer? Featured on Meta. Now live: A fully responsive profile. Reducing the weight of our footer. Show 1 more comment. Kousha Kousha 1, 14 14 silver badges 18 18 bronze badges. Evan Carroll Mars Robertson Mars Robertson Apparently I haven't read the git docs well enough, or my glasses need updating ;- — Dennis. This doesn't seem to get the file from a remote repository though, like the OP needs. Or: git show HEAD:. Kind request for all downvoters - please explain and clarify what's not OK - we are here to learn and share : — Mars Robertson.
MichalStefanow: Mike Weller has it; specifically, this doesn't work on a remote repository. You need a local clone at the very least, even if you then have remotes set up on it. Steven Penny Steven Penny 1.
To connect to raw. This works for public repositories only. For private repositories you need authentication. Willem van Ketwich Willem van Ketwich 4, 7 7 gold badges 47 47 silver badges 53 53 bronze badges. This does not work, github does not support git archive. You explicitly set --remote to a github URL in your answer though ;- — Philipp.
Thanks for the feedback. Have amended the answer accordingly. Richard Lalancette 2, 23 23 silver badges 29 29 bronze badges. ATorras ATorras 3, 2 2 gold badges 28 28 silver badges 35 35 bronze badges.
For single file, just use wget command. A while the file will put in your folder. For example for downloading modules from different repositories.. Here's a script:! Community Bot 1 1 1 silver badge. Shayki Abramczyk Shayki Abramczyk It requires api token, doesn't it? Depends how you run the api — Shayki Abramczyk. Oliver Pearmain Oliver Pearmain This is specific for git repos hosted on GitHub Try the 'api' command of Github's command line app, gh , to make an authenticated call to Github's 'get repository contents' endpoint.
JasonS JasonS 6, 5 5 gold badges 37 37 silver badges 58 58 bronze badges. Fernanda Martins Fernanda Martins 81 1 1 silver badge 5 5 bronze badges. Christopher Shroba Christopher Shroba 5, 4 4 gold badges 31 31 silver badges 57 57 bronze badges. This answer may help make sparse clone, that is without overhead.
If your goal is just to download the file there's a hassle-free application called gget : gget github. Granitosaurus Granitosaurus Hector Llorens Hector Llorens 5 5 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name.
0コメント