I usually create new branch from develop
git checkout -b new-feature develop
then after the last commit I merge back to develop
git checkout develop git merge new-feature
but this time I created new-feature2
brach from new-feature
and now I cannot merge to develop
.
Is there a way to switch new-feature2
's parent to develop
?
(The files I worked on were the same version as in develop
so this should not require merging.)
The easiest way is to check git log and note your commit hashes, checkout your right branch and do: git cherry-pick h4sh . Other way is to checkout the right branch and merge it the one which you worked, but then it'll merge the other changes as well, so it depends if you want to do that.
Make sure you are on the branch to which you have been committing. Use git log to check how many commits you want to roll back. Then undo the commits with git reset HEAD~N where “N” is the number of commits you want to undo. Then create a new branch and check it out in one go and add and commit your changes again.
Note: Be sure to have a clean workspace before you begin. Read all messages git shows you. If in doubt, read more about the topic before starting.
You could rebase your feature over to the main base:
git checkout new-feature2 git rebase --onto develop new-feature new-feature2 # rebase the stuff from new-feature to new-feature2 onto develop branch
or do it 'manually' by using cherry pick
git checkout develop git log --oneline new-feature..new-feature2 # for every commit call: git cherry-pick <commit-id> # note, newer versions of cherry-pick allow multiple commits at once
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