2

我是 git 和 github 的新手(我之前使用过 Subversion)。我找不到解决方案,如何仅将主分支从我的私有存储库导出到我的生产服务器。

我需要准备一个自动化解决方案(通过结构调用)。我发现 git 有存档命令,但这不适用于 github(我设置了 SSH 密钥):

someuser@ews1:~/sandbox$ git archive --format=tar --remote=git@github.com:someuser/somerepository.git master
Invalid command: 'git-upload-archive 'someuser/somerepository.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

所以我需要另一种方法来做到这一点。我不想在导出中使用来自 git 的任何元文件。当我克隆时,我会将所有这些文件放在 .git 目录中(我不想要),这会下载比我真正需要的更多的数据。

有没有办法通过 ssh 做到这一点?或者我只能通过 HTTPS 下载 zip 文件?

4

2 回答 2

2

我不确定我是否完全理解你的问题。

我使用此命令将当前主版本拉到我的服务器:

curl -sL --user "user:pass" https://github.com/<organisation>/<repository>/archive/master.zip > master.zip

这有帮助吗?

于 2012-11-14T11:36:57.277 回答
0

正如我在SO answer on download GitHub archives from a private repo中解释的那样,在创建GitHub 访问令牌后,您可以使用wgetcurl获取所需<version>的 repo(例如masterHEAD提交 SHA-1,...)。

解决方案wget

wget --output-document=<version>.tar.gz \
    https://api.github.com/repos/<owner>/<repo>/tarball/<version>?access_token=<OAUTH-TOKEN>

解决方案curl

curl -L https://api.github.com/repos/<owner>/<repo>/tarball/<version>?access_token=<OAUTH-TOKEN> \
    > <version>.tar.gz
于 2014-09-11T08:49:42.773 回答