git export from github remote repository

前端 未结 10 1307
北恋
北恋 2020-12-07 13:50

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

10条回答
  •  爱一瞬间的悲伤
    2020-12-07 14:49

    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.

提交回复
热议问题