1

I have a git issue I need suggestions to.

I'm not a git pro, just decent I'd say, and this is nerve wrecking. Let's say there's this big project the company is working on and my team is developing a feature so we create a new branch from the master and work on that one and we call this an epic just as in Agile. The epic has hundreds of tasks and we create a new branch for each one of them and then merge it back once it's complete.

By working in the same file, obviously there will be quite a lot of merge conflicts and these are resolved by each programmer and this is how I ended up with a colleague of mine deleting some of my methods while merging his branch back into the epic. Now I want to put my methods back but I can't merge the branch again in the epic. Here's where my git understanding gives up on me and PhpStorm and GitKraken can't merge the branch back to the epic because it's already there. And that's true, but there are still some differences between them (AKA my methods are missing... crying)

My question is: What's the procedure in cases like these to bring my methods back?

Also, my colleagues kinda left me alone to deal with this and I can't find anything on Google that's somewhat similar to my situation.

Thanks and cheers!

Daniel Bejan
  • 1,468
  • 1
  • 15
  • 39
  • I found a similar problem, maybe it helps you: https://stackoverflow.com/a/42584170/5757830 – Luca Sep 27 '18 at 10:44

2 Answers2

0

Find the last commit before the bad merge in the epic branch. You can checkout the code in that stage by using the revision code (Rollback to an old Git commit in a public repo).

Then create a new branch from that commit (Branch from a previous commit using Git)

Merge the branch that caused the conflict in the epic into your branch and resolve the conflicts

Merge epic into your branch and resolve the conflicts

Verify correctness of changes and merge back into the epic

Dimitris
  • 560
  • 3
  • 17
  • Ohh man.. That sounds sooo complicated.. I'll give that a try tomorrow when I'll be back at the office.. Will keep you updated – Daniel Bejan Sep 27 '18 at 15:29
  • The alternate is merge out from the current epic, cherry pick your code and do the fixes yourself in this branch. – Dimitris Sep 28 '18 at 07:29
  • I ended up deleting the missing bits of code from my branch, pushing and merging, then undo the deletion, push and merge again and after fixing the conflicts myself, things look like back to normal again.. Thanks again for your time :) – Daniel Bejan Oct 03 '18 at 07:07
0

What I finally ended up doing is looking manually into the files and seeing what's missing.

Then I checked out my branch, deleted the methods that were missing from the epic branch, pushed on my branch and merged into epic, and then undo the deletion of the methods, push again on my branch and merge into epic. After resolving the conflicts myself, things started to work again.

Luckily there were just a few methods missing and some routes in the routes file.

Daniel Bejan
  • 1,468
  • 1
  • 15
  • 39