32

我通常在我的内部使用以下命令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/

有什么建议么?谢谢

4

2 回答 2

42

来自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

但是,如果您只是提取 repo,您​​可以使用以下--depth参数进行浅克隆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.

所以你有这样的事情:

$ git clone --depth=1 https://kave@dndigital.git.cloudforge.com/myoproject.git
于 2012-12-06T19:33:42.663 回答
0

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

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

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

于 2020-07-10T01:57:42.463 回答