从存储库中检索单个文件 [英] Retrieve a single file from a repository

查看:75
本文介绍了从存储库中检索单个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是最有效的机制(就数据传输和磁盘空间而言)从远程git存储库获取单个文件的内容?



远远我设法得到:

  git clone --no-checkout --depth 1 git@github.com :foo / bar.git&& cd bar&& git show HEAD:path / to / file.txt 

这看起来似乎过分了。



如何从repo获取多个文件?

解决方案

in git version 1.7.9.5这似乎工作从远程导出单个文件

  git archive --remote = ssh:// host / pathto / repo.git HEAD README.md 

这会捕获文件的内容, README.md


What is the most efficient mechanism (in respect to data transferred and disk space used) to get the contents of a single file from a remote git repository?

So far I've managed to come up with:

git clone --no-checkout --depth 1 git@github.com:foo/bar.git && cd bar && git show HEAD:path/to/file.txt

This still seems overkill.

What about getting multiple files from the repo?

解决方案

in git version 1.7.9.5 this seems to work to export a single file from a remote

git archive --remote=ssh://host/pathto/repo.git HEAD README.md

This will cat the contents of the file README.md.

这篇关于从存储库中检索单个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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