我怎样才能完全清空Git中的主分支? [英] How can I completely empty the master branch in Git?

查看:1657
本文介绍了我怎样才能完全清空Git中的主分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想完全清空Git中的主分支。现在,我还想保留所有其他已经从主分支的分支。



这是可能的吗?


这将创建一个新的主分支分支指向初始提交:

  git分支-D master 
git checkout -b master< initial commit hash>

这将创建一个与您无关的全新主分支:

  git分支-D master 
git checkout --orphan master
git rm -rf *

但实际上您可以简单地将当前存储库保存到其他位置,然后创建一个新存储库。


I would like to completely empty the master branch in Git. For now, I would also like to keep all other branches which have been branched from master.

Is this possible and how?

解决方案

That's actually called "delete old master branch and create new from scratch"

This will create a new master branch pointing to initial commit:

git branch -D master
git checkout -b master <initial commit hash>

This will create a totally new master branch unrelated to whatever you had:

git branch -D master
git checkout --orphan master
git rm -rf *

But actually you can simply save current repository to some other place and create a new repository instead.

这篇关于我怎样才能完全清空Git中的主分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆