I am facing a problem while merging forward my code.
Let say there are 2 branches names Jan2024 & Feb2024.
The Feb2024 branch was created from the Jan2024 branch as base branch. During the time when the Feb2024 branch was created, the Jan2024 branch had only 3 files: A.txt, B.txt and C.txt. But later both the branches had changes made where some files were added/modified.
The Jan2024 branch has the below files after changes were made:
A.txt #Existing file
B.txt #Exisitng file
C.txt #Existing file but updated to show the text -> "January code changes"
D.txt #Newely added file
E.txt #Newely added file
The Feb2024 branch has the files:
A.txt #Existing file
B.txt #Existing file
C.txt #Existing file but updated to show the text -> "February code changes"
F.txt #Newely added file
G.txt #Newely added file
When trying to merge forward from Jan2024 to Feb2024 there was a conflict occurred in file C.txt because it was modified in both the branches. I had resolved the conflict by updating the file in the web editor to show the text “January code changes” in both the branches.
After clicking on merge commit and Merging the branches I was shocked to see what had happened. Not only were the added/modified files from Jan2024 were merged to the Feb2024 branch but also the files added/modified in Feb2024 were merged to the Jan2024 branch. All this happened within one pull request which clearly says we are trying to merger Fan2024 to Feb2024. But I don’t know how the Feb2024 was merged back into the Jan2024.
This is how the below branches looked after the merge forward which is not what I expected.
Jan2024 branch:
===============
A.txt #Existing file
B.txt #Exisitng file
C.txt #Existing file which shows the text -> "January code changes"
D.txt #Newely added file
E.txt #Newely added file
F.txt #Newely added file from Feb2024 branch
G.txt #Newely added file from Feb2024 branch
Feb2024 branch:
===============
A.txt #Existing file
B.txt #Existing file
C.txt #Existing file which shows the text -> "January code changes"
D.txt #Newely added file from Jan2024 branch
E.txt #Newely added file from Jan2024 branch
F.txt #Newely added file
G.txt #Newely added file
But this is how I expected the below branches to look after the merge forward. But unfortunately it didnt.
Jan2024 branch:
===============
A.txt #Existing file
B.txt #Exisitng file
C.txt #Existing file which shows the text -> "January code changes"
D.txt #Newely added file
E.txt #Newely added file
Feb2024 branch:
===============
A.txt #Existing file
B.txt #Existing file
C.txt #Existing file which shows the text -> "January code changes"
D.txt #Newely added file from Jan2024 branch
E.txt #Newely added file from Jan2024 branch
F.txt #Newely added file
G.txt #Newely added file
When I tried Reverting the pull request I can see that the D.txt and E.txt were removed from the Feb2024 branch but F.txt and G.txt were not removed from the Jan2024 branch.
Also I tried removing the files F.txt and G.txt from the Jan2024 branch but after removing when I compared Jan2024 and Feb2024 branches its not identifying the files D.txt and E.txt which need to be pushed to the Feb2024 branch. Instead its identifying the files F.txt and G.txt as files which need to be removed from the Feb2024 branch when trying to merge Jan2024 to Feb2024.
Whatever I tried seems to be worsening the existing problem. Kindly suggest a way to remove the F.txt and G.txt from the Jan2024 branch and at the same time merge Jan2024 to Feb2024 so that the Feb2024 branch looks like what I expect above.
mohammed adnan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.