I have the master branch like this:
A->B->C->D->E
The develop branch like this:
A->B->C->D->E->F->G->H->I
^
|- This should be used
I want to apply G
on top of D
. How can I do this?
I tried this:
git checkout develop
git rebase 82c7b6a
But that is giving me merge conflicts.
My main goal is to keep the master branch and delete the develop branch.
main: A->B->C->D->G->H->I
I would cherry-pick that one commit.
git checkout master
git cherry-pick G
git cherry-pick H (EDIT 3)
git cherry-pick I (EDIT 3)
git branch -D develop
EDIT
I didn't see that you don't want E. Then it would be:
git checkout master
git reset --hard HEAD^1
git cherry-pick G
git cherry-pick H (EDIT 3)
git cherry-pick I (EDIT 3)
git branch -D develop
EDIT 2
More failsafe solution would be as pointed out by @ckruczek to use rebase interactive.
git checkout master
git reset --hard develop
git rebase -i D
git branch -D develop
And remove the lines with the commits you don't want to have.
EDIT 4
As it is a history rewrite you might get serious trouble using the upper approaches.
I would recommend a solution like:
A->B->C->D->E->!E->G->H->I
To get that do: git checkout master git revert E git cherry-pick GHI git branch -D develop
If you are the only user try this.
1. git checkout develop
2. git rebase --onto master~1 F I /* move commits G, H and I on master~1 (D) */
3. git checkout I
4. git rebase master
finally you can delete the branch develop
7. git branch -D develop
If you want to skip E
- F
you could do fully explicit rebase:
git rebase --onto master G~1 develop
you will have to resolve potential conflicts.
When you are done you may move your master and drop develop:
git push . develop:master
git checkout master
git branch -d develop
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.