在一个压扁的公共和私人初始分割git回购 [英] Split git repo in a squashed public and initial private
问题描述
我想在Github上开源项目。
为了开始一个清理工作,我需要将很多提交(超过2k)压缩到一个初始提交中代码库和隐藏一些历史的东西。
问题是,是否有可能: 谢谢。
您可以在当前的回购中非常高效地执行此操作:
$ b
从以下开始:
#...--- o --- H HEAD, master
do
git cat-file -p master \
| sed'1,/ ^ $ / d'\
| git commit-tree HEAD ^ {tree} \
| xargs git branch public
得到
#...--- o --- H HEAD,master
#
#H'public < - H确切的内容和提交消息,无历史记录
然后,
git merge -s our public
#...--- o --- H --- I HEAD,master< - 稍后将合并一个精确的基
#/
#H''public
git remote add public -t public its:// u / r / l#< - '-t public`设置默认推送
git push public
完成了。
(编辑:添加 -t public
安全播放,所以你必须做一些明确的操作来推送非公开的历史记录)
I want to open-source a project on Github.
There is quite a lot of commits (more than 2k) that I would squash into one "Initial commit" in order to start with a clean codebase and hide some historical stuff.
The question is, is it possible to:
- keep a private repo (on which there will be some secret keys, travis conf, ...) with all initial commits
- have a clean public codebase (all commits squashed into one)
- and work on the public repo and "merge" when needed on the private without any kind of conflicts ?
Thanks.
You can do this very efficiently in your current repo:
Starting from:
# ...---o---H HEAD, master
do
git cat-file -p master \
| sed '1,/^$/d' \
| git commit-tree HEAD^{tree} \
| xargs git branch public
to get
# ...---o---H HEAD, master
#
# H' public <-- H's exact content and commit message, no history
Then,
git merge -s ours public
# ...---o---H---I HEAD, master <-- gives later merges an accurate base
# /
# H'' public
git remote add public -t public its://u/r/l # <-- '-t public` sets default push
git push public
and you're done.
(edit: added -t public
safety play so you have to do something explicit to push non-public history)
这篇关于在一个压扁的公共和私人初始分割git回购的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!