neogit icon indicating copy to clipboard operation
neogit copied to clipboard

Solving merge conflicts

Open ilAYAli opened this issue 4 years ago • 12 comments

There are a few operations that are currently more intuitive with GUI tools, resolving merge conflicts and visually staging selected hunks. Neogit excels at the former, and https://github.com/samoshkin/vim-mergetool does a remarkably good job at simplifying the process of solving merge conflicts.

With vim-mergetool, the only think you need to do, is to open a file with conflict marks, type :MergeToolToggle, and get a very simple two way split. Merging becomes a matter of :diffthis / :diffother. When you are done, type :MergeToolToggle again.

I would love to see this feature in Neogit, to have one intuitive git plugin that can handle both of these visual tasks.

ilAYAli avatar May 12 '21 07:05 ilAYAli

I believe vim already supports merges by default using :h diff so we can reuse the diff view code for this once merged.

I recently had a lot to do in a different OS project of mine so I kept this one more in the backlog. I now have more free time so I should be able to finish this PR as well as this feature. (As long as I am not misscoping this atm)

TimUntersberger avatar May 13 '21 17:05 TimUntersberger

Perfect! Yes, vim supports :diff, it but does not, afaik, understand git hunks, so the merging leaves a lot to be desired. Merging not just hunks, but visually selected lines, as you already support with staging, would make this plugin second to none. Great work!

ilAYAli avatar May 13 '21 20:05 ilAYAli

@ilAYAli, you can use https://github.com/lewis6991/gitsigns.nvim for this purpose.

Shatur avatar May 17 '21 10:05 Shatur

@Shatur95 gitsigns is somewhat beneficial for indicating changes, but does not help with the merge process. Complex merging often requires selecting only certain (partial) lines of a hunk, on a finer granularity than e.g git add -p. This, preferably with a two/three way diff, similar to the plugin I mentioned above, is what I hope can be implemented in Neogit.

ilAYAli avatar May 17 '21 11:05 ilAYAli

@ilAYAli, it also allows you to stage changes, check it out. But granular staging is in progress.

Shatur avatar May 17 '21 11:05 Shatur

@Shatur95 Nice, I didn't know that! I would still like this feature in Neogit, where it sounds more appropriate than git signs ;)

ilAYAli avatar May 17 '21 11:05 ilAYAli

I would still like this feature in Neogit, where it sounds more appropriate than git signs ;)

I think that when you are just editing text, it is also convenient to be able to stage hunks that you see, not only in diff. If this functionality is in Neogit, then staging will be handled differently in two different plugins. I don't think it makes sense to reinvent the wheel. Any signs plugin will work without any issues with Neogit (there are also other plugins that work with signs and support staging). Just my opinion.

Shatur avatar May 17 '21 12:05 Shatur

The current plan is to implement merge conflict resolution in diffview.nvim and then just reuse the existing integration to support this.

I think that when you are just editing text, it is also convenient to be able to stage hunks that you see, not only in diff. If this functionality is in Neogit, then staging will be handled differently in two different plugins

I think this isn't a problem, because these are just separate workflows. Someone might prefer the infile staging whereas someone else might want to have staging be a separate thing.

I don't think it makes sense to reinvent the wheel

I also don't want to reinvent the wheel that is why I am currently deferring this kind of work to diffview.nvim.

Just my opinion.

👍

TimUntersberger avatar May 17 '21 12:05 TimUntersberger

The current plan is to implement merge conflict resolution in diffview.nvim and then just reuse the existing integration to support this.

Of course, @ilAYAli just asked about staging and I only answered about staging hunks.

I think this isn't a problem, because these are just separate workflows. Someone might prefer the infile staging whereas someone else might want to have staging be a separate thing.

There might be hotkey conflicts... But any plugin that support staging works fine with diffview.nvim right now (gitsigns for example).

Shatur avatar May 17 '21 13:05 Shatur

There are a few operations that are currently more intuitive with GUI tools, resolving merge conflicts and visually staging selected hunks. Neogit excels at the former, and https://github.com/samoshkin/vim-mergetool does a remarkably good job at simplifying the process of solving merge conflicts.

With vim-mergetool, the only think you need to do, is to open a file with conflict marks, type :MergeToolToggle, and get a very simple two way split. Merging becomes a matter of :diffthis / :diffother. When you are done, type :MergeToolToggle again.

I would love to see this feature in Neogit, to have one intuitive git plugin that can handle both of these visual tasks.

HI sir, I tried pasting the nmap from the documentation into my vimrc but still the hotkey doesn't work, can you share how you add hotkey to MergetoolToggle?

laleeroy avatar Feb 12 '22 01:02 laleeroy

The current plan is to implement merge conflict resolution in diffview.nvim and then just reuse the existing integration to support this.

Isn't it what you were expecting from diffview https://github.com/sindrets/diffview.nvim/pull/205 ?

You can maybe just add in NeogitStatus a part to see Conflicted Files, but to resolve these conflicts diffview seems to solve the problem.

EpiCanard avatar Sep 08 '22 11:09 EpiCanard

@ilAYAli, you can use https://github.com/lewis6991/gitsigns.nvim for this purpose.

how?

Vinni-Cedraz avatar Apr 03 '23 19:04 Vinni-Cedraz