I just did a bad thing with my git repo and I don't know how to solve it.
I basically have two branches, let's say develop
and feature
, which I constantly update. At one point I changed a couple of files on the branch develop
. I also needed these changes in the feature
branch, so instead of doing it again there I made a merge between the two branches only applying these changes (and discarding all the other files changes/conflicts). After that I just made some commits just to the feature
branch.
That worked as I wanted but with a big problem. Now I need to merge the two branches (the develop
into the feature
) completely but when I try to do it nothing happens. I actually know why nothing happens (git thinks the two branches are already merged and the only changes are in the feature
branch. It's the same as I try to merge a branch that I just created) but I still need to complete the merge with the old changes.
To better understand this in the situation example:
develop o--c--1-- --2-- --o-
\ \
feature \ --o-- --b-- -\m--o-
b: commit before wrong partial merge
1: changes applied in the m commit (after wrong merge
2: changes NOT applied in the m commit (after wrong merge
m: result of partial merge
As explained in the m
commit I just have the changes of the 1
and not the changes of the 2
. If I try to merge the develop
into the feature
now the 2
changes are lost.
I came up with a couple of solutions but I'm not sure if any of that can actually work:
- I could checkout to the
b
commit so I can merge all the changes from thedevelop
. Then I can commit the changes and merge them with the currentfeature
branch - I could create a complete new branch (let's say
temp
) from thec
commit. Then I can copy all the content of thefeature
branch into the temp branch without actually merging but just copying the files. Then I commit the resulting changes and then merge the newtemp
branch with thedevelop
. Finally I can copy the resulting content to thefeature
branch so it's stay aligned.
I think that the second option could actually work well but I'm not really sure.
To finish, in the second option I tried to save the feature
branch to keep the repo in order. But I don't really need to preserve the feature
branch as I would delete it soon or later when the feature is actually complete.
Anyone knows a better way to help me with this problem?
Thank you in advance