Git:如何直接从远程存储库存档?

时间:2012-12-06 18:33:05

标签: git

我通常在project.git内使用以下命令获取指定目的地的存档:

git archive master | tar -x -C /home/kave/site/

我想知道是否可以直接从远程存储库归档到目标目录?

我尝试过这样的事情,没有任何快乐:

git archive master https://kave@dndigital.git.cloudforge.com/myoproject.git | tar -x -C /home/kave/site/

有什么建议吗?感谢

2 个答案:

答案 0 :(得分:30)

来自git help archive

   --remote=<repo>
       Instead of making a tar archive from the local repository, retrieve a tar archive from a remote repository.

命令最终应该像:

$ git archive --remote=https://kave@dndigital.git.cloudforge.com/myoproject.git master

但是,如果您只是提取回购,则可以使用--depth的{​​{1}}参数进行浅层克隆:

git clone

所以你有这样的事情:

   --depth <depth>
       Create a shallow clone with a history truncated to the specified number of revisions. A shallow repository has a number of limitations (you cannot clone or fetch from it, nor push from nor into it), but is adequate if you are only interested in the recent history of a large project with a long history, and would want to send in fixes as patches.

答案 1 :(得分:0)

另一个专门针对GitHub的选项是github-backup。它具有捕获特定于GitHub的功能的选项,例如问题,Wiki等。这是我最近用来为其他人的存储库进行归档的示例命令行:

github-backup --all --pull-details --prefer-ssh --repository REPO REPO-OWNER -u mhucka

在上面的命令中, REPO-OWNER 代表目标存储库的所有者,而 REPO 是存储库名称。