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
For a normal export:
$ git archive master | tar -x -C /path/to/destination
For a zip archive:
$ git archive --format zip --output /path/to/destination/file.zip master
Of course for this to work, you'll need to clone it locally first, there's no clean way around that.
One way to achieve this is to use the SVN support offered by GIT.
Steps to perform as root one off are (for Cent os);
yum install git
yum install subversion
Then to do a selective export the following syntax should be used:
svn export <git repository>/<source folder> <empty target folder> --no-auth-cache --force --username <active directory username>
If you do not use parameter --no-auth-cache when prompted to save the password type "no" for security reasons, or it will be saved unencrypted.
When translating from the GIT notation to the SVN notation the following mapping applies; replace "tree/master" with "trunk" for master replace "tree/branch_name" with "branches/branch_name" for branches
This works for both files and directories.
Thanks to the Subversion support by GitHub, you can use svn export
to get the project without any version control files:
svn export https://github.com/user/project/trunk
Notice the URL format:
https://github.com/
USERNAME/PROJECTNAME
without .git
/trunk
appended at the endThis way you can get branches and subdirectories too.
This creates a directory with the exported files. It's not possible to create a tar/zip directly, you have to do in two steps (export + zip). This is a limitation of svn export
itself.
As @Jon pointed out, this will create the export in a directory named trunk
by default. You can specify a different name if you prefer:
svn export https://github.com/username/projectname/trunk projectname
You can use this technique to export any sub-directory of the project.
For example if you want only some/path
, you can do:
svn export https://github.com/username/projectname/trunk/some/path local-dir-name
You can get paths from branches and tags too. The endpoint https://github.com/username/projectname
behaves fully as a Subversion repository with a regular layout, so you will find branches in https://github.com/username/projectname/branches
and tags in https://github.com/username/projectname/tags
.
Before you export something large by mistake, it's good to check first the content of the path. You can do that using svn ls
, for example:
svn ls https://github.com/username/projectname/
Normally this should give you:
branches/
tags/
trunk/
You could iteratively explore the repository this way.
If your goal is to limit the quantity of information exchanged with the server, have you considered using clone
with --depth
? You would still need to remove the (much reduced) .git
subdirectory though:
git clone --depth=1 git@github.com:xxx/yyy.git && rm -rf yyy/.git