我到底应该做什么才能
git checkout -b new_one; git cherry-pick commit_id
,我是对的吗?)new_one
重命名为master
? 当然,任何改变都应该被推到远程。
感谢。
答案 0 :(得分:2)
为了获得一个只持有一个提交的新主服务器,最简单的方法是创建一个新的repo,然后将当前状态master
作为初始状态放入其中。否则,您将始终拥有master
目前的历史记录:
git archive --format zip --output /full/path/to/zipfile.zip master
git init .
git add . && git commit -m "initial"
remote
:git remote add ...
master
的新状态推送到那里:git push -f origin master:master
然后,您的repo将只有一个分支(master
)只有一个提交。
答案 1 :(得分:1)
从new_branch
开始创建commit_id
:
git branch new_branch commit_id
查看它:
git checkout new_branch
删除旧的master
分支:
git branch -d master # you may need to use -D, with history loss may occur
将new_branch
重命名为master
:
git branch -m new_branch master
请注意,这并不一定会删除所有历史记录 - 即使您执行完整的垃圾回收,commit_id
所引用的任何对象都将保留在git历史记录中(以及git对象存储库)。
答案 2 :(得分:0)
我会尝试这样的事情:
git branch tmp <the very first commit in the repo>
git checkout tmp
git merge --squash <commit_id>
git branch -d master
git branch -m tmp master
......然后强制推送