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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13750182/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 15:03:23  来源:igfitidea点击:

Git: How to Archive from remote repository directly?

git

提问by Houman

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

我通常在我的内部使用下面的命令project.git来获取指定目标中的存档:

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://[email protected]/myoproject.git | tar -x -C /home/kave/site/

Any suggestions? Thanks

有什么建议?谢谢

回答by mgarciaisaia

From git help archive:

来自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://[email protected]/myoproject.git master

But, if you would just extract the repo, you can make a shallow clone using --depthparameter of git clone:

但是,如果您只是提取 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.

So you have something like this:

所以你有这样的事情:

$ git clone --depth=1 https://[email protected]/myoproject.git