1

I fixed half of my merge conflicts in PyCharm's diff tool, then decided I wanted to fix some of them in the plain text file, since it's full width. So I clicked "Apply", and now I have a file with <<<<<<HEAD in it that doesn't show up in the Resolve Conflicts window.

How can I finish the merge? I looked at https://stackoverflow.com/a/47712453/733092 to try to continue merging from the command line, but I couldn't figure out what to put in for pycharm merge <left file> <right file> [<base file>] <output file>.

My current plan is to copy the text of the file the way it is, abort the merge, restart, and paste it into the new merge window. But then I have to ignore all the changes I fixed already.

I also want to know this because people check in half-merged files and I would like to be able to continue those merges.

Noumenon
  • 5,099
  • 4
  • 53
  • 73
  • 1
    So I clicked "Apply" - that is the mistake: it "accepted" the merge. You can just close the window. – danuker Jun 08 '21 at 12:44

1 Answers1

1

You could check the status in command-line, to see if the "Apply" in pyCharm completley terminated the merge or not.

If the git status is clean, then you can simply open you file with conflict merge marker, modify it (to keep only ours or theirs), removing the <<<</>>>> markers, add and commit.

Regarding PyCharm, you could set it up as the default merge tool

[merge]
    tool = pycharm
    keepBackup = false
[mergetool "pycharm"]
    cmd = /usr/local/bin/pycharm merge "$LOCAL" "$REMOTE" "$BASE" "$MERGED"

Then all you need to do is:

git mergetool -- yourFile_with_conflict_markers_in_it
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • `git status` has the other unmerged files, but not this one. – Noumenon Mar 19 '20 at 14:52
  • The point of the question is to avoid editing by hand and return to the visual merge. I have never been able to read the `<<<<`. – Noumenon Mar 19 '20 at 14:53
  • 1
    @Noumenon I understand, but those markers are not complex to process: https://stackoverflow.com/a/7901901/6309, https://stackoverflow.com/a/16389292/6309 – VonC Mar 19 '20 at 15:26
  • If that's the answer, that's the answer. I'm learning that skill. But it's much harder when you don't get them side by side with highlights on which part of the line actually changed. – Noumenon Mar 19 '20 at 15:35
  • @Noumenon I fully agree. I don't know enough PyCharm to know if you can open that file in a diffmerge fashion, but you have other GUI tools which can act as merge tools: https://stackoverflow.com/q/137102/6309. You could use one to open just that one file, using the `git mergetool --tool=aTool -- aFile` command. – VonC Mar 19 '20 at 15:40
  • @Noumenon Actually, I have edited the answer with a possible solution using PyCharm. – VonC Mar 19 '20 at 15:42
  • Thanks for that -- I had set that up but thought you needed four files for the syntax to work and didn't continue. Unfortunately, when I run it it tells me `No files need merging`. Have an upvote anyway, you're very helpful. – Noumenon Mar 19 '20 at 16:11
  • Wait a sec (sorry for being chatty), I don't see the <<<< in my test file. Let me look. – Noumenon Mar 19 '20 at 16:12
  • OK, so it turns out that clicking "Apply" destroys all the markers in the file -- nothing left to merge. However, your mergetool tip will help me merge other people's unfinished merges. Thank you very much. – Noumenon Mar 19 '20 at 16:17
  • How my original file got `<<<<` in it, I don't know. It even had them in the visual window, which is unusual. – Noumenon Mar 19 '20 at 16:18