I have a following situation:
root -- A -- D ------------- H ------master
\ \ \
\ \ \
- B -- C -- E -- F -- G -- I -- J -- dev
Commit 'F' contains an bugfix that at first seemed to be unrelated to master branch, but after few weeks it proved to be important. Everything was already commited and pushed.
But another problem is that 'F' commit contains a few changes and only one of them is relevant to master. So what I would want to is:
I don't need to change dev branch history.
Can I do anything besides manual diff + patch?
I imagine something like
root -- A -- D ------------- H ---K--master
\ \ /-------\--/
\ \ /-F1-F2-\ \-----\
- B -- C -- E ------- F -- G -- I -- J -- dev
(sorry for sloppy line art)
I would do the following: first cherry-pick commit F with --no-commit
to your master branch, then stage the changes you need in master, drop everything else. I know it does not sound like the perfect solution, but when merging F to master, you would also get all ancestor commits of F (from dev branch: E C B):
git checkout master
git stash
git cherry-pick --no-commit F
git reset && git add -p
# alternatively reset already staged changes:
git reset -p
git commit
git reset --hard
git stash pop
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With