I have a develop branche and a feature branche, when finishing the feature I want to merge it into develop. Conflicts arise so, I first pull develop into feature to resolve it then commit the modifications BUT :
I commit only the file with the conflict resolved and forget the rest. So when I merge feature into develop it rollback lots of commits...
origin develop> ----o-c-c-c-o-------m------
\ \ /
local feature> f-------m-r-o
The commits 'c' are merge with feature but when merging again with develop I forgot them.
How can I solve this ?
I'm not very experimented with git so i'm asking to have an answer more specific to my problem than the everage git reset response
origin develop> ----o1-c1-c2-c3-o2---------m2------
\ \ /
local feature> f1----------m1-r1-o3
You mistake is in commit m1 and the changes propagated further down the chain.
The cleanest solution to this problem would be rewriting history so everything is is still flowing correctly. However, this breaks history for every, so they need to reset their branch to the new head, only recommended if you seen your mistake before you pushed.
The fix is redoing the merge, then redoing the final merge with the master.
on branch: feature: git reset --hard f1
We are going back to the state of the branch at commit f1
on branch: feature: git merge o2
Redo our merge, making sure we aren't discarding our index this time
on branch: feature: git cherry-pick r1
Include the changes introduced in commit r1
on branch: feature: git cherry-pick o3
Include the changes introduced in commit o3
on branch: feature: git push -f
Force push our fixed feature branch
on branch: feature: git checkout develop
Switch to develop, so we can fix it
on branch: develop: git reset --hard o2
We are going back to the state of the branch at commit o2
on branch: develop: git merge feature
Redo the feature to master branch merge, this fixes the whole chain.