git rebase 多个分支

标签 git git-rebase

我想简化这个 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/

相关文章:

Git:如何在没有以前所有历史记录的情况下挑选提交

git - 如果仅在个人分支上重新定位推送的提交

git - 64 位 Windows 7 上的 msysGit

git - 在本地从 Detached HEAD 进行一系列提交后,如何更新远程分支?

git - 我怎么知道 repo 将 "push"到哪里?

Git 重置(不难)然后快进 merge 某些提交

git - 试图推送到 BitBucket 但我得到 "master conq: repository access denied." "fatal: The remote end hung up unexpectedly"

git - 无法使用 rebase pull

git - merge 后如何 rebase ?

git - 如何在跳过特定提交时 rebase ?