git 仓库新建一个与其它提交历史完全无关的分支
2024年10月4日小于 1 分钟
1. 使用 --orphan
git checkout --orphan [branch_name]
git commit -a参考:git - How to push new branch without history - Stack Overflow
2. 从新仓库引入新分支
先建立新仓库 /path/to/unrelated,有默认分支 master
再回原仓库,
cd /path/to/repo
git fetch /path/to/unrelated master:unrelated-branch这样就有了 unrelated-branch,/path/to/unrelated 可以删除了
参考:In git, is there a simple way of introducing an unrelated branch to a repository? - Stack Overflow