[英]How do I split a git repository(by branch)
I started with a piece of code which got split into two small programs each in a different branch. 我从一段代码开始,该代码被分成两个小程序,每个小程序都在不同的分支中。
They share a lot of similarities but I'd like to split them into 2 repos so I can work on both at the same time in an easier fashion. 它们有很多相似之处,但我想将它们分成2个存储库,这样我就可以同时以更轻松的方式同时处理这两个存储库。 It's annoying to have to commit a change(and get rid of/commit unimortant changes (such as gitignore and makefile flags) before switching context before switching.
在切换上下文之前必须先提交更改(并摆脱/提交唯一的更改(例如gitignore和makefile标志)),这很烦人。
It's a pretty simple linear one person history except for that early split and a few unneeded stashes. 这是一个非常简单的线性一人历史,除了早期的分裂和一些不必要的隐藏。
What's the best way to accomplish it? 最好的方法是什么?
最简单的方法是仅克隆存储库,并可能删除克隆的存储库中不需要的分支。
Even simpler 更简单
mkdir program1
cd program1
git init
git pull ../origrepo smallprogram1
rinse, repeat 冲洗,重复
If you have stuff in a branch history that shouldn't be in that history any more, see git-filter-branch
(eg --index-filter 'git rm unwanted-bits'
) and you're good to go 如果您在分支历史记录中有不应该再存在的内容,请参阅
git-filter-branch
(例如--index-filter 'git rm unwanted-bits'
),您可以开始使用
Don't forget to vacuum on your way out ( git gc --prune=...
or git repack
) 不要忘记在出门时清理(
git gc --prune=...
或git repack
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.