【问题标题】:How to export a subdir from git branch [duplicate]如何从 git 分支导出子目录 [重复]
【发布时间】:2013-07-07 13:21:51
【问题描述】:

我正在寻找 git 中的 svn export 的等价物。但我实际上只想导出一个子目录。我的结构如下所示:

/db
/html
/tools
...

我只想导出 repo 中的 /html 目录,从给定的分支(比如说master)到 fs 上的某个目录,但没有内部 .git 目录并省略 .gitignore 文件下的文件.理想情况下是这样的:

cd my_repo_dir
git export master/html/* /var/www/my_website_docroot

我可以这样做吗?如何做?

【问题讨论】:

标签: git


【解决方案1】:
git checkout-index -f --prefix=/path/to/folder/ html/*

【讨论】:

  • 这表示html/*中的每个子目录“不在缓存中”
  • 这是一个低级命令,因此它没有递归选项来处理子目录。您必须自己找到所有子目录中的所有文件并将其传递给命令,例如find html/ -type f | git checkout-index -f --prefix=/path/to/folder/ --stdin
  • @Veseliq,如果 git 无法识别 html dir..add 并提交所有内容,然后尝试
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2010-11-18
  • 1970-01-01
  • 2018-05-12
  • 1970-01-01
  • 2021-03-07
  • 1970-01-01
  • 2016-05-04
相关资源
最近更新 更多