GIT:签出到特定的文件夹 [英] GIT: Checkout to a specific folder

查看:105
本文介绍了GIT:签出到特定的文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用类似的东西:

  git checkout  - < path> /< file> 

但我想将文件签出到我选择的某个文件夹,而不是覆盖本地/。

有什么想法? 做一个git导出 (如svn export)?



您可以使用 git checkout-index ,这是一个低级别的命令,如果你想导出所有内容,你可以使用 -a

  git checkout-index -a -f --prefix = / destination / path / 

引用手册页:


最后的/[在前缀]上很重要。导出的名字实际上只是以指定的字符串为前缀。


如果您想导出某个目录,则会涉及一些技巧。该命令只接收文件,而不是目录。要将其应用到目录,请使用'find'命令并将输出传输到git。

git checkout-index --prefix = / path-to / dest / -f -z --stdin

同样来自手册页:


直觉性不是这里的目标。重复性。



I want to use something similar to:

git checkout -- <path>/<file>

but I want to checkout the file to some folder I choose, rather than the overwriting the local /.

Any idea?

解决方案

As per Do a "git export" (like "svn export")?

You can use git checkout-index for that, this is a low level command, if you want to export everything, you can use -a,

git checkout-index -a -f --prefix=/destination/path/

To quote the man pages:

The final "/" [on the prefix] is important. The exported name is literally just prefixed with the specified string.

If you want to export a certain directory, there are some tricks involved. The command only takes files, not directories. To apply it to directories, use the 'find' command and pipe the output to git.

find dirname -print0 | git checkout-index --prefix=/path-to/dest/ -f -z --stdin

Also from the man pages:

Intuitiveness is not the goal here. Repeatability is.

这篇关于GIT:签出到特定的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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