git rebase多个分支

时间:2014-08-01 21:40:44

标签: 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        

我试图改变:

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命令?

1 个答案:

答案 0 :(得分:2)

最简单的方法是检查提交08273d5,然后检查83bc4db中的所有文件到工作目录,然后创建一个新的分支并提交更改,即(从顶级目录)

git checkout 08273d5
git checkout 83bc4db -- .
git checkout -b newbranchname
git commit -m "Some message"