Open rogerxu opened 7 years ago
How do I download a specific git commit from a repository? - Stack Overflow
Do a "git export" (like "svn export")? - Stack Overflow
Excluding files from git archive exports using gitattributes
Git - git-archive Documentation
git archive [--format=<fmt>] [--list] [--prefix=<prefix>/] [<extra>]
[-o <file> | --output=<file>] [--worktree-attributes]
[--remote=<repo> [--exec=<git-upload-archive>]] <tree-ish>
[<path>…]
Example:
git archive -v --format=zip --output=archive.zip --remote=git@github.com:rogerxu/webpack-demo.git master app/images
git - How to download .zip from GitHub for a particular commit sha? - Stack Overflow
You can put the sha that you want in the download url:
https://github.com/{username}/{projectname}/archive/{sha}.zip
As a general rule, if you have a url that works, you can replace "master" with the specific sha you want.
git archive --remote
As far as I know Github does not allow archive --remote
for HTTPS protocol. git archive
works fine with GitHub, as long as you use the ssh protocol.
git archive -v --format=zip --output=archive.zip --remote=git@github.com:rogerxu/webpack-demo.git master app/images
svn export
How to download a project subdirectory from GitHub (Example)
svn export https://github.com/rogerxu/webpack-demo/trunk/app/images archive
1.1.0-SNAPSHOT
=> branch rel-1.1
2.0.0
=> tag 2.0.0
2.0.1-SNAPSHOT
=> branch rel-2.0
2.1.0-SNAPSHOT
=> branch develop
Sometimes we need to download a specific version of a project from a Git repository to do some work like build from source code. If clone the entire repository it will be very slow because we don't need the entire commit history.
GitHub provides a download as zip service for a specific version which meets our needs. But how about a Git repository accessed via SSH?