I\'d like to export from github remote repository, not cloning it. Similar to svn export, I do not want to get .git folder with it. I can work around it by cloning and remov
If you're only interested in exporting from GitHub then they provide a mechanism to download tarballs. For example:
https://github.com/torvalds/linux/downloads
Even though it says "there aren't any downloads for this repository." you can still use the buttons to download a tarball of the master branch.
Or see this link for a list of tarballs linked to tags:
https://github.com/torvalds/linux/tags
This should work for any GitHub repo, not just the linux kernel.
If you need this for named commits (that is branches and tags), then you can use git clone --depth=1
combined with git archive
It is worth knowing that git clone --depth=1
clones all top commits on all branches and tags (not only master
). So after doing such a shallow clone you can enter the local directory and make a git archive --format=tar tag_to_be_exported
.
So if you want to export the tag release1.1
git clone --depth=1 git@github.com:xxx/yyy.git
cd yyy
git archive --format=tar release1.1 -o release1.1.tar
So unnless you need to export unnamed commit-ids, this may be a good solution.
If you need to get a tarball of a commit on github I think this is the easiest way:
Say your repository name is
https://github.com/arielgabizon/librustzcash
and the commit id is
4be41ca6160c16abfd983c8c878b6ea04105b224
Just go in your browser to the address
https://github.com/arielgabizon/librustzcash/archive/4be41ca6160c16abfd983c8c878b6ea04105b224.tar.gz
and, at least on google chrome, it will start downloading the file.
I think it is not possible to export github repository with git archive. Please read this
https://help.github.com/articles/can-i-archive-a-repository
Only possible ways are
git clone
github download (ZIP) button
For unknown (to me at least) reasons GitHub doesn't support this.
We don’t support people running git-archive against our servers.
Seems silly, since via SVN you can, but... I upvoted @Janos' answer.
I ran into this same problem before, and AFAICT, it only seems to work with Bitbucket, e.g.
ysim:~/repos$ git archive --format=tar --prefix=alembic/ --remote=ssh://git@bitbucket.org/zzzeek/alembic.git master | tar -xf -
ysim:~/repos$ ls
alembic
But I found a workaround for GitHub using wget - so in the new GitHub interface, you'll find a button that says "Download ZIP" on the bottom of the right sidebar; right-click on it and copy the link address.
Next, in the command line (I got the idea from here):
wget -qO- -O tmp.zip <zipball url> && unzip tmp.zip && rm tmp.zip
That will unzip it to a directory called something like repo-master/
.
If you want, you can also alias this in your .gitconfig
so you don't have to remember/type all of that out, e.g.
export = "! f() { wget -qO- -O tmp.zip \"$1\" && unzip tmp.zip && rm tmp.zip; }; f"
So you can just do something like this in the shell:
ysim:~/repos$ git export https://github.com/ysim/verbinski/archive/master.zip
ysim:~/repos$ ls
verbinski-master