Git Rebase or Merge! What do I do?
It’s very common for developers to work on the same files for different reasons. And here comes the problem with updating branches once someone else merges their code before you do.
Usually, there are some known methods
git rebase
git merge
In both cases, getting into conflict is pretty common. When you have a conflict, it takes a lot of time and mental energy to resolve it and make sure that they do not overwrite or remove whatever you did.
Sometimes, I even noticed that necessary codes were gone or unnecessary codes were added after resolving the conflict 🫠
So what do I do?
I start with git merge. If the conflict is less than 5-10 lines. I solve it using simple manual conflict resolution.
But if there are lots of conflicts?
Then I abort the merge.
I just opened a new branch from the latest main branch.
And copy the codes from the active feature branch(the branch where the conflict happened) to that new branch
It’s painfully manual work, BUT most of the time those are less than 10 min work and SAFE.