I have some difficult to found a Git generic worflow to remove some commits (between 2 refs) from a branch ; here is a little example :
My current state are like this :
* a878646 (develop) C8a
* 070acb7 C7a
| * 7937ce7 (HEAD, F1) C9b
| * fb4add2 C8b
| * 30456de C7b
|/
* 6a0999e C6
* 45ae978 C5
* e8a2eeb (tag: T3, master) C4
* 24b98b2 (tag: T2) C3
* c874fc7 (tag: T1) C2
* a853900 C1
I want to test "F1" on my plateform, but ONLY the commits of "F1" on master.
In other word, I would like that F1 becomes like this :
* 7937ce7 (HEAD, F1) C9b
* fb4add2 C8b
* 30456de C7b
* e8a2eeb (tag: T3, master) C4
* 24b98b2 (tag: T2) C3
* c874fc7 (tag: T1) C2
* a853900 C1
So I have to remove commits C5 and C6.
After the tests, F1 should be merge on master.
But, these commits have to stay on "develop" branch, because after that I have to do a "git checkout develop && git rebase origin/master"
The result on develop should be :
* a878646 (HEAD, develop) C8a
* 070acb7 C7a
* 6a0999e C6
* 45ae978 C5
* 7937ce7 C9b (tag: T4, master)
* fb4add2 C8b
* 30456de C7b
* e8a2eeb (tag: T3) C4
* 24b98b2 (tag: T2) C3
* c874fc7 (tag: T1) C2
* a853900 C1
Is there a way to accomplish that simply ? This problem is recurrent, and I search another way than doing it with multiple "cherry-pick" one comits by one commits...
I search a way just using "master", "F1", and without knowing number of commits bewteen these branches and in F1 :/
I think I can maybe use "rebase onto" but I don't really understand how...
Many thanks !
Using
rebase --onto
or
Using
git rebase -i
Using
git cherry-pick
Note that commit hashes will be different than on your "result on develop" list (in every version).