Reputation: 135
I have three commits:
* d868098 Three
* 865eb70 Two
* 6dd085d One
And I want to move 'Three' directly onto 'One':
* 865eb70 Two
|
| * d868098 Three
|/
* 6dd085d One
However, nothing I'm trying is working. For example, git rebase --onto 6dd0 865e d868
simply rewinds HEAD but doesn't rebase anything. How can I achieve this using rebase
?
Update: Okay, git rebase --onto 6dd0 865e d868
does work. It wasn't working for me before because I was trying this on a test repository that had only empty commits. As soon as I created meaningful commits, everything worked as expected. I will avoid empty commits for testing in the future!
Upvotes: 2
Views: 197
Reputation: 2409
To do that, you need at least 2 branches.
I assume you are on master
branch which refers to * d868098 Three
.
git reset --hard 865eb70
(remove * d868098 Three
from master
)git checkout -b three_brach
(create and move to new branch)git checkout 6dd085d
git cherry-pick d868098
(pick * d868098 Three
to three_branch
branch)Now the tree is below
* 865eb70 Two (master)
|
| * d868098 Three (three_branch)
|/
* 6dd085d One
Upvotes: 1