我一直在想是否有一个很好的"git export"解决方案,它创建了一个没有.git
存储库目录的树的副本.我知道至少有三种方法:
git clone
然后删除.git
存储库目录.git checkout-index
提到这个功能,但开头是"只需将所需的树读入索引...",我不完全确定如何做.git-export
是第三方脚本,基本上git clone
进入临时位置,然后rsync --exclude='.git'
进入最终目的地.这些解决方案都没有让我感到满意.最接近的一个svn export
选项可能是选项1,因为这两个都要求目标目录首先为空.但是假设我可以弄清楚将树读入索引意味着什么,选项2似乎更好.
该git clone --depth
命令选项说
--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.
Run Code Online (Sandbox Code Playgroud)
为什么浅克隆有这种限制?为什么它只是一个补丁工作流程?
对于某些项目工作流程,我需要将最新的提交从单个分支传递给编码器,然后让它们能够push
(快进)开发到主服务器.这部分是为了安全,知识产权保护和回购规模,部分是为了减少大回购会给天真编码员带来的困惑.是否有允许这样的git工作流程?
更新:根据Karl Bielefeldt的回答,git checkout --orphan …