Skip to content

Instantly share code, notes, and snippets.

@simonw
Last active July 7, 2024 18:45
Show Gist options
  • Save simonw/a44af92b4b255981161eacc304417368 to your computer and use it in GitHub Desktop.
Save simonw/a44af92b4b255981161eacc304417368 to your computer and use it in GitHub Desktop.
How to create a tarball of a git repository using "git archive"
@forty
Copy link

forty commented Nov 15, 2022

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

@amidevous
Copy link

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

@yskelg
Copy link

yskelg commented Jun 30, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment