git 创建全新分支
要在当前仓库创建一个不包含任何文件的新分支,可以使用以下Git命令:
git switch
<!--more-->
--orphan <new-branch-name>
git commit --allow-empty -m "Initial commit"
这两个命令的解释:
-
git switch --orphan <new-branch-name>:-
创建并切换到一个新的孤立分支。
-
这个分支不会有任何提交历史。
-
-
git commit --allow-empty -m "Initial commit":-
创建一个空的初始提交。
-
没有这个提交,分支技术上还不存在。
-
执行这些命令后,你将得到一个全新的、不包含任何文件的分支。