git archive --format=tar.gz -o /tmp/my-repo.tar.gz --prefix=my-repo/ master
More detailed version: https://til.simonwillison.net/git/git-archive
git archive --format=tar.gz -o /tmp/my-repo.tar.gz --prefix=my-repo/ master
More detailed version: https://til.simonwillison.net/git/git-archive
It would be clearer if projects compressed file named as 'repo-master.tar.gz', it is a disruptive annoyance by naming them like that.
Imagine one needing to download more than one project compressed file in a script. eg: me :D
Well it's easy enough to specify a different output name, e.g. with wget
's -o
argument.
This popped up as a result in a web search, so in case it's useful to anyone, I'll mention here that if the repo is on Github, you can also download a tarball of any repo directly, e.g.
wget https://github.com/User/repo/archive/master.tar.gz
and
master
can be any ref, e.g. a tag.
@purcell
This is the single most useful thing I've learned today. Already saving me so much time... Thanks!
This is the single most useful thing I've learned today. Already saving me so much time... Thanks!
I know, right? Super handy. Happy tinkering!
It may be worth mentioning here that for GitHub, there is also github-backup
. It has options to capture GitHub-specific features like issues, wikis, and so on. (This is not meant to take away from the original answer or the utility of git archive
. Also, I'm not associated with github-backup
– just a satisfied user.)
This popped up as a result in a web search, so in case it's useful to anyone, I'll mention here that if the repo is on Github, you can also download a tarball of any repo directly, e.g.
wget https://github.com/User/repo/archive/master.tar.gz
and
master
can be any ref, e.g. a tag.
🤯
Just putting this here, it's not ideal but if you have a private repo and just want to fetch it:
Generate GitHub access token: https://github.com/settings/tokens
And use token like this:
https://<personal_token>:@github.com/<your_repo>/archive/main.tar.gz
It's no ideal solution as you will have to recreate the token over time and each dev who wants to use the repo needs their own token.
This works on git repositories that are not Github
git archive --format=tar.gz -o my-repo.tar.gz --remote=git://sourceware.org/git/glibc.git master
Note that it doesn't work on Github as it appears it doesn't support it isaacs/github#554
for subfolder not work please solve download github subfolder project
example
wget https://github.com/User/repo/archive/master/folder.tar.gz
not work return 404 error please solve or propose solution for work
download github subfolder project in tarball
thank you
This solution available.
wget https://github.com/torvalds/linux/archive/refs/heads/master.zip
This previous solution was not available(why?)
$ wget https://github.com/User/repo/archive/master.tar.gz
--2024-06-30 15:22:42-- https://github.com/User/repo/archive/master.tar.gz
Resolving github.com (github.com)... 20.200.245.247
Connecting to github.com (github.com)|20.200.245.247|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2024-06-30 15:22:42 ERROR 404: Not Found.
This popped up as a result in a web search, so in case it's useful to anyone, I'll mention here that if the repo is on Github, you can also download a tarball of any repo directly, e.g.
and
master
can be any ref, e.g. a tag.