git export from github remote repository

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 removing .git folder. I wonder if there is a cleaner way?

I read it somewhere you can use git archive to achieve this.

However I got the following errors..

$ git archive --format=tar --remote=git@github.com:xxx/yyy.git master | tar -xf -

Invalid command: 'git-upload-archive 'xxx/yyy.git''
You appear to be using ssh to clone a git:// URL.
Make sure your core.gitProxy config option and the
GIT_PROXY_COMMAND environment variable are NOT set.
fatal: The remote end hung up unexpectedly

Any help would be great. Thanks.


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:

  • The base URL is https://github.com/
  • USERNAME/PROJECTNAME without .git
  • /trunk appended at the end
  • This 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 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 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
    
    链接地址: http://www.djcxy.com/p/90452.html

    上一篇: 为什么GitHub中分叉库的大小如此之大?

    下一篇: 从github远程仓库中输出git