I have the following situation:
A stable version of the application has appeared in the master branch.
Developer Recently created a branch with branch-a functions with several commits (let them be a-1 , a-2 , a-3 ). The implemented functions here are based on the updated code from the wizard and are well tested at the moment.
Developer B had a branch function named branch-b with several commits (e.g. b-1 , b-2 , b-3 ). For some reason, Mr. B had an outdated version (based on the state of the owner a week or two ago) in his functional branch and did not test the code at all.
Both developers combined their function branches for management using:
- git check wizard
- git pull origin master
- git merge branch-X (where X = a, b)
- git push origin master
The rebase command was not used. This sequence was first performed by B, then by A.
When I (the C developer) pulled out of the wizard, I saw in git log something like:
- a-merge: merge with the master using developer A
- a-3
- a-2
- a-1
- b-3 (yes, this fixation occurs immediately after the merger)
- b-merge-conflict: merge with master developer B (thousands of file conflicts)
- B-2
- B-1
- master-stable: previous stable commits
As a result, Mr. B somehow forced the old version of the code to overwrite the stable version when merging (as a result, b-merge-conflict commit was performed).
NOW I want to rewrite the story and save b-1 + b-3 + a-1 + a- 2 + a-3 and cancel b-2 , b-merge-conflict and a-merge .
My idea is to undo a few top commits to b-1 , and then use the cherry curl patch to apply b-3 , a-1 , a-2 , a-3 the new master commits.
BUT when I try:
git reset --hard HEAD ~ 7 I can see a history containing only old commits (until master stable), without the history of branches-a and branch-b.
When I try:
git reset --hard HEAD ~ 2
I see in history only a master-stable commit at the top, but NOT a-2 as I want.
It seems that git reset does not translate the digit after HEAD as the number of commits to reset (as I understood from the documentation), but as the number of HEAD changes to git pull (in my examples there are 2).
How can I correctly undo the first 7 commits of b-2 .. a-merge and rewrite history starting with b-1?
UPDATE set in comments
I used (without --all to exclude additional information)
git log --online --decorate --graph
* ef7d93f Merge with master by Developer A |\ | * 2b9dd31 b-4 | * 924a452 b-3 | * 1f9489d b-2 | * e3cd7a6 Merge by Developer B [2]: Merge branch 'master' from https://github.com .... | |\ | * | aece506 Merge by Developer B [1]: merge branch | * | 487e7ee b-1 * | | d9404f8 a-1 | |/ |/| * | 9b202ce master-stable last commit