Currently I have this complicated merged commits tree :
* 36cd4ff merge commit to rebase 12 (master,origin/master,HEAD)
|\
| * f8d22cf merge commit to rebase 11
| |\
| | * 4381ba4 merge commit to rebase 10
| | |\
| | | * c81227f commit to rebase 9
| * | | d16e5ca commit to rebase 8
* | | | c277df7 good 7
* | | | e712ceb good 6
|/ / /
* | | 80e3baa good 5
* | | 1559030 good 4
|/ /
* | e8bf45c good 3
* | 4ca2d92 good 2
|/
* d43f5ac good 1
I would like something like that (to rewrite clean history with a git push --force) :
* 36cd4ff merge commit to rebase 12
* f8d22cf merge commit to rebase 11
* 4381ba4 merge commit to rebase 10
* c81227f commit to rebase 9
* d16e5ca commit to rebase 8
|
* c277df7 good 7
* e712ceb good 6
* 80e3baa good 5
* 1559030 good 4
* e8bf45c good 3
* 4ca2d92 good 2
* d43f5ac good 1
If I do git rebase -i HEAD~6, only these commits appears :
pick 80e3baa good 5
pick e712ceb good 6
pick c277df7 good 7
pick d16e5ca commit to rebase 8
pick c81227f commit to rebase 9
pick 4381ba4 merge commit to rebase 10
where these commits have gone ?
* f8d22cf merge commit to rebase 11
* f8d22cf merge commit to rebase 11
The only ‘solution’ so far that has worked was to clone the repository and starting from
c277df7 good 7, copying files from source repo and doing a commit.
if you rebase, you solve all your merge-conflicts with the rebase.. so you dont need seperate merge-commits.. so first of all – revert all your merge-commits and then try the following:
until “good 7” you have a straight commit-line, after that you will have to put each commit on top of the tree (which has 7 as base)
put rebase 8 on top of rebase 7:
then put 9 on 8:
solve all merge-conflicts along the way (you might have to do other commits or amend to your commit)
before you do anything, I suggest you do a backup of the repo by making a copy of the folder (you could rewind everything with git reflog, but sometimes a copy is just easier)
good luck
edit: if you dont want to lose the “merge-commits” then you can rebase the whole “merge-commit-branch” on top of commit 8 by doing rebase d16e5ca 36cd4ff (after the first rebase, of course)