git从github远程仓库导出 [英] git export from github remote repository
问题描述
我想从 github 远程存储库导出,而不是克隆它.与 svn export 类似,我不想用它获取 .git 文件夹.我可以通过克隆和删除 .git 文件夹来解决它.不知道有没有更干净的方法?
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?
我在某处读到它,你可以使用 git archive 来实现这一点.
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.
推荐答案
感谢 GitHub 对 Subversion 的支持,您可以使用 svn export
获取项目,无需任何版本控制文件:
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
注意 URL 格式:
- 基本 URL 是
https://github.com/
USERNAME/PROJECTNAME
没有.git
/trunk
附加在最后
- 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.
这将创建一个包含导出文件的目录.无法直接创建 tar/zip,您必须分两步进行(导出 + zip).这是svn export
本身的限制.
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.
正如 @Jon 指出的那样,这将在名为 trunk
的目录中创建导出默认情况下.如果您愿意,可以指定不同的名称:
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
您可以使用此技术导出项目的任何子目录.例如,如果你只想要 some/path
,你可以这样做:
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
您也可以从分支和标签获取路径.端点 https://github.com/username/projectname
完全表现为具有常规布局的 Subversion 存储库,因此您将在 https://github.com/username/中找到分支projectname/branches
和 https://github.com/username/projectname/tags
中的标签.
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
.
在错误导出大文件之前,最好先检查路径的内容.你可以使用 svn ls
来做到这一点,例如:
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/
通常这应该给你:
branches/
tags/
trunk/
您可以通过这种方式迭代地探索存储库.
You could iteratively explore the repository this way.
这篇关于git从github远程仓库导出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!