命令

命令:checkout –orphan

git checkout --orphan 的核心用途是在非新存储库上以类似 git init 的状态创建分支。

即基于当前所在分支建立一个没有提交记录的新分支,相当于拷贝当前所在分支的所有文件到新分支,同时没有父结点。

使用

建立新分支

1
git checkout --orphan  new_branch

添加所有文件变化到暂存空间

1
git add .

提交并添加记录

1
git commit -m "first"

删除当前分支

1
git branch -D master

重命名当前分支为 master

1
git branch -m master

强制推送到远程仓库

1
git push -f origin master