Git:如何直接从远程存储库进行存档? [英] Git: How to Archive from remote repository directly?

查看:83
本文介绍了Git:如何直接从远程存储库进行存档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常在我的 project.git 中使用下面的命令来获取指定目的地的档案:

I usually use the command below inside my project.git to get an archive in the specified destinations:

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

我是否可以直接从一个远程仓库,而不是一个目的地目录?

I wonder if its possible to archive directly from a remote repository instead into a destination directory?

我尝试过这样的事情,没有任何喜悦:

I tried something like this, without any joy:

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

有什么建议吗?谢谢

Any suggestions? Thanks

推荐答案

From git help archive

From git help archive:

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

命令应该如下所示:

Command should end up like:

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

但是,如果您只提取回购,您可以使用 - 深度参数 git clone

But, if you would just extract the repo, you can make a shallow clone using --depth parameter of 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

这篇关于Git:如何直接从远程存储库进行存档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆