1、使用 --orphan
选项建立孤立分支
git checkout --orphan empty-branch
2、清除工作区内的所有内容
git rm -rf .
3、创建提交来初始化新分支
echo '# title' >> README.md
git add README.md
git commit m "First Commit"
4、推送新分支到远端仓库
git push origin empty-branch
版权属于:wshon
本文链接:https://blog.wshon.com/2022/10/git-empty-branch.html
转载时须注明出处及本声明
最新回复