git-get
is a git extension that makes it a little easier to download files stored in a remote git repository. Use it when you just want the repo's files and won't be making changes to the code, or will be commiting it to a different repo and dont need to retain the repo's history.
git-get
also allows you to pull down the repo, or just a branch's working directory, as a zip or tar file that includes all its submodules and respects the export-ignore
rules that appear in .gitattributes. This isn't possible at all with git alone.
Install the latest release (includes pre-releases)
curl -L https://raw.githubusercontent.com/ajdruff/git-get/master/git-install.sh | bash
Install a specific branch or release
git clone https://github.com/ajdruff/git-get.git
#git clone --branch v0.0.1-pre-release https://github.com/ajdruff/git-get.git # for a specific branch or release
cd git-get
sudo chmod +x ./git-get
sudo cp ./git-get $(dirname $(which git))/
sudo cp ./parser/git-get-parser.sh $(dirname $(which git))/
git get https://github.com/tailwindcss/tailwindcss.git
git get -z https://github.com/tailwindcss/tailwindcss.git
-t can be used to give a tar archive instead
Using just git, you can do almost everything that git get
lets you do, but you'll need to do it in multiple steps.
git get
allows you to add a project's files to your project without having to add it as a submodule or manually deleting its .git folder.git get
will automatically include all the submodules needed for the project (without their corresponding git directories by default)git get
can easily get a zip or tar of a repo, complete with its submodules. Although the git builtingit archive
supports zip and tar, it doesnt include a projects submodules.
git-get
allows you to download a zipped archive that includes all submodules and follows the export-ignore rules in a repository. .
To do that, simply pass the -z ( for zip ) and -x ( for export rules )
git get -zx https://github.com/githubtraining/hellogitworld.git
There are alternatives, all of which require writing a not-insignificant script. A Google search shows you that this is not solved yet; some suggestions include this old stackoverflow question and a script.
What you want to do | Using just git |
Using git get |
---|---|---|
download all files in master except the .git directory | git clone https://path/to/repo.git ;cd repo; rm -rf .git | git get https://path/to/repo.git |
download all files except .git directory as an archive in tar.gz format | git clone https://path/to/repo.git; cd repo; git archive -o latest.tar.gz HEAD | git get -t https://path/to/repo.git |
download all files except .git directory as an archive in zip format | git clone https://path/to/repo.git; cd repo; git archive -o latest.zip HEAD | git get -z https://path/to/repo.git |
clone a repository | git clone https://path/to/repo.git | git get -k https://path/to/repo.git |
A few examples using a sample repository.
git get https://github.com/githubtraining/hellogitworld.git
git get -k https://github.com/githubtraining/hellogitworld.git
git get -b git-pages https://github.com/githubtraining/hellogitworld.git
git get -b RELEASE_1.1 https://github.com/githubtraining/hellogitworld.git
git get -z https://github.com/githubtraining/hellogitworld.git
git get -t https://github.com/githubtraining/hellogitworld.git
git get -zx https://github.com/githubtraining/hellogitworld.git
git get -zxk https://github.com/githubtraining/hellogitworld.git
Usage: git get [--branch BRANCH] [--zip] [--tar] [--export] [--keep-repo] [--dry-run] [--verbose]... [--version] [--help] <repository> [<directory>]
Options:
-b BRANCH, --branch BRANCH The branch you want to download. [default: master].
-z, --zip Download as zip [default: off].
-t, --tar Download as tar.gz [default: off].
-x, --export When used in combination with -z or -t, abides by export-ignore rules in .gitattributes. [default: off].
-k, --keep-repo Keep the .git directory [default: off].
-d, --dry-run Uses system tmp directory for downloads so doesnt clutter current directory. Ignored when used with -a [default: off].
-V VERBOSE, --verbose VERBOSE Set verbose output (can be specified multiple times to increase the effect) [default: 0].
-v, --version Prints version.
-h, --help Prints help.
You must have the following already installed:
git
zip
Written by Andrew Druffner andrew@nomstock.com