从git存储库中提取树的最佳方式是什么? [英] What's the best way to extract a tree from a git repository?

查看:101
本文介绍了从git存储库中提取树的最佳方式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过 git show 从任意版本中提取Blob(文件)很容易,例如:

  git show master:src / hello-world.c> /tmp/hello.c 

但是,我想知道是否有类似的方法git以递归方式提取树(目录)和它下面的所有东西?



我写了一个小脚本来完成这个任务,所以我将其添加为一个可能的答案。看起来,这是一种很好的东西,可能是内置于git,但我不知道如何找到它...

解决方案

 <$ c $   c> git archive master:src / | tar -C目的地-x 


Extracting a blob (file) from an arbitrary revision is easy with git show, e.g.:

 git show master:src/hello-world.c > /tmp/hello.c

However, I'd like to know if is there a similar way in git to extract a tree (directory) and everything under it recursively?

I've written a small script that does this, so I'll add that as a possible answer. It seems that this is the kind of thing that may well be built in to git, but I just don't know how to find it...

解决方案

You can use git archive for this.

git archive master:src/ | tar -C destination -x

这篇关于从git存储库中提取树的最佳方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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