Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

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 [email protected]: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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...