So I have 3 branches;
develop
- my continued development branchversion_1
- a release branchversion_2
Merging only one or a few commits mean using git cherry-pick
First cancel the merge you just did: see "Undo a Git merge?".
Then:
git checkout version_1
git cherry-pick <commit checksum>
That can apply to multiple commits or a range of commits: see "How to cherry pick a range of commits and merge into another branch".
You need to cherry-pick those commits.
Switch to the branch where you want to add the commits:
git checkout develop
Then, cherry-pick
the commit. First do a git reflog
and get the SHA-1
of the commit of the hotfix.
Then, while you are on the branch develop
, cherry-pick
it
git cherry-pick <commit SHA obtained above>
Perform similar actions on the other branch version_1
.