-2

What steps can I take when I encounter conflicts while merging my code in Git?

Step 1:I add a change in brand "test"

Step 2:And next, I add a change in brand "new"

And when I want to merge these two brands. It shows some conflicts, and I don't know how to figure out problem

Dgbtlard
  • 11
  • 1
  • https://stackoverflow.com/search?q=%5Bgit%5D+resolve+merge+conflicts – phd Feb 17 '23 at 19:02
  • One thing you can do is [use KDiff3](https://github.com/hlovdal/git-resolve-conflict-using-kdiff3) to resolve the conflicts. That is a way better tool than something that just show embedded conflict markers from just two versions. – hlovdal Feb 18 '23 at 09:15

2 Answers2

0

I believe you are talking about "branch" new and "branch" test.

So generally a merge conflict tends to happen when you make changes to the same file in different branches, and Git doesn't know how to automatically resolve the changes.

Here is documentation on how to resolve merge conflicts from GitHub - https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line

What you would need to do is decide whether change A (from branch "test") must overwrite all changes, or Change B (from branch "new") should overwrite all changes or whether both changes need to be kept in the file, alternatively you could modify each line and choose which changes to keep.

Let me know if that helps.

luke_bermont
  • 1
  • 1
  • 2
-1

You need to go to your workplace and type the command "git diff", which will show you the difference between the two branches. And then you can see an announcement in the head of your change and you can merge the code by your hand. Hopes to help you.

Richard-zrx
  • 201
  • 13