In master branch I have below commits:
A-B-C-D-HEAD
In branch "test" I have:
A
I did:
git cherry-pick <SHA FOR COMMIT C>
However, I don't want commit B on "test" branch. How can I ignore that? so that test branch end up like: A-C
In master branch I have below commits:
A-B-C-D-HEAD
In branch "test" I have:
A
I did:
git cherry-pick <SHA FOR COMMIT C>
However, I don't want commit B on "test" branch. How can I ignore that? so that test branch end up like: A-C
You can do this: (Assuming master points to D)
1. (master) git-checkout -b test
2. (test) git rebase -i
You will have a list of commits like:
pick b6e7d38 A
pick 263b0cc B
pick 6bcea1d C
pick 6kdf8gd D
Just delete the commit that you don't want (B and D here). Save and continue, It will be omitted while rebasing.
The best option according to me would be git format-path
.
Step1: (master) git format-patch -2
Step2: (master) git checkout -b test <SHA of Commit-A>
Step3: (test) git am 0002-Commit-Msg-of-C
You are good to go!
Explanation: Step1 will create 2 patch-files, one for commit D and one for C. In Step3 you are applying the patch(changes) made while commit-C over A(test points to A, step2)
Hope this helps!
PS: This will work if your changes in B are unrelated to changes in C.