我想简化这个 Git 历史记录,其中包含 几个 Git 分支:
* 83bc4db
|\
| * 66c64f9
| * 32c1a93
| * 8b5fd0c
| * 501454e
| * b316bac
| |\
| * | 6d8f409
| * | ca9747a
| * | fa37e88
| |\ \
| * | | 97ce58e
* | | | e56b9df
* | | | 33441b7
* | | | e5b2606
* | | | dbb039e
* | | | 68f3082
* | | | 17774ea
* | | | 1945fbd
| |_|/
|/| |
* | | 8c3b38d
| |/
|/|
* | d0aaef1
|/
* 08273d5
* 2f8652a
* 0e3d8df
进入单个提交:
* XXXXXXX
* 08273d5
* 2f8652a
* 0e3d8df
我尝试使用以下方法进行 rebase :
git rebase -i 08273d5
然后像这样修改 git-rebase-todo :
pick d0aaef1
squash 8c3b38d
squash 1945fbd
squash 17774ea
squash 68f3082
squash dbb039e
squash e5b2606
squash 33441b7
squash e56b9df
squash 97ce58e
squash ca9747a
squash 6d8f409
squash 501454e
squash 8b5fd0c
squash 32c1a93
squash 66c64f9
Git 说:
error: could not apply 97ce58e... merge done
When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To check out the original branch and stop rebasing run "git rebase --abort".
Could not apply 97ce58e... merge done
要发出哪些 Git 命令?
最佳答案
最简单的方法是 checkout 提交 08273d5,然后将 83bc4db 中的所有文件 checkout 到工作目录中,然后创建一个新分支并提交更改,即(从顶级目录)
git checkout 08273d5
git checkout 83bc4db -- .
git checkout -b newbranchname
git commit -m "Some message"
关于git rebase 多个分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25089084/