microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.5k stars 29.38k forks source link

Support 3 way merge for git conflicts #37350

Closed asydneylover closed 2 years ago

asydneylover commented 7 years ago

IntelliJ, and all other IntelliJ-based IDE such as WebStorm, support a git merge's conflict resolution tool that it shows the conflict in three columns:

Please see my attached file. merge-conflict-resolution

I find that it's super easy for us to resolve conflict, because I can compare the Local Changes and the Server Changes on the same windows, and I can see the Resolution Result immediately.

Can we please support that?

Auwalms commented 6 years ago

This will be a super cool feature, I use VSCode for my day job but often resort to WebStorm when I need to resolve a merge conflict due to its interactivity and ease to use.

Nodragem commented 6 years ago

Any news on this? this feature would be amazing. On one hand, there is a diff tool (i.e. comparing two files) in VS code, but you cannot edit / chose what to keep; on the other hand, there is a merge conflict tool that allows to chose what to keep (current change / their change). Now, the best would be to have both tools into one tool, such as the tool suggested by @uyhung.

I also wanted to add, for any contributor who comes by: VS Code is an amazing piece of software, keep it up :) !

uvaldez commented 6 years ago

That will be an amazing feature... any news on it? does anyone recommend some extension that does something similar?

krzysztofwolski commented 6 years ago

I'm using that on PyCharm. Such amazing feature, it helps a lot with avoiding bugs on bigger merges. All linters are available during process, so errors/style violations/unused variables are easy to spot.

millanbrankovic commented 6 years ago

Please hurry up with this feature if you're planning to implement it :)

igocooper commented 6 years ago

Thumb up đź‘Ť for this one. That's the only thing holding my back to totally switch to VSCode. Would be super helpful and handy.

VladimirTyalo commented 6 years ago

The day you implement this feature I will stop using webstorm.

argordmel commented 6 years ago

Not only to resolve conflicts, this design should be available to see the history file too.

OJFord commented 6 years ago

git config merge.conflictStyle diff3 and you have this today but with VSCode's in-editor layout - which is vastly better than popping up a dialogue and a new window to view the file you already had open IMO!

VladislavAnkudinov commented 6 years ago

Any news? Is it scheduled maybe, or planned to be scheduled?

menvil commented 6 years ago

Yes really needed

ltsharma commented 6 years ago

this is much needed feature, im using inteliij idea just to resolve conflicts.

TimoWestland commented 6 years ago

+1, this would be awesome!

yannickbuntsma commented 6 years ago

+1 here! Trying to make the switch, but IMO this is one of the major features missing to switch from WebStorm to VSCode

Zielak commented 6 years ago

Can we please stop with the +1 comments? It brings nothing to the conversation. Just watch this thread and wait...

stephanmullerNL commented 6 years ago

@Zielak +1 let's stop adding more comments

rajjejosefsson commented 6 years ago

Anyone know if there is any plugin that can make this possible ?

OJFord commented 6 years ago

@rajjejosefsson As I said above, you can set: (git config merge.conflictStyle diff3)

[merge]
  conflictStyle = diff3

to see them/common/us. It won't change the VSCode formatting/theme, but you will get those three parts to your diff instead of just them/us as is the (git) default.

Unless there's something else (other than opening multiple dialogues just to get back to view a diff in the file you already had open) that JetBrains IDEs offer that I'm missing here?

smbkr commented 6 years ago

The newly released Sublime Merge has a similar implementation.

tsachit commented 6 years ago

This will be a super cool feature, I use VSCode for my day job but often resort to WebStorm when I need to resolve a merge conflict due to its interactivity and ease to use.

You can add these configuration in your .gitconfig file and type "git mergetool" on your terminal whenever conflict appears. It'll only open your merge gui interface from webstorm for each file.

[mergetool "webstorm"]
    cmd = webstorm merge $(cd $(dirname "$LOCAL") && pwd)/$(basename "$LOCAL") $(cd $(dirname "$REMOTE") && pwd)/$(basename "$REMOTE") $(cd $(dirname "$BASE") && pwd)/$(basename "$BASE") $(cd $(dirname "$MERGED") && pwd)/$(basename "$MERGED")
    trustExitCode = true
[merge]
    tool = webstorm
giordanocardillo commented 5 years ago

+1 here, is now the only reason I use webstorm!

krsiakdaniel commented 5 years ago

+1

rsimmonsjr commented 5 years ago

+1

logusgraphics commented 5 years ago

True, VS Code is amazing except for the lack of this UI tool.

moonfruit commented 5 years ago

+1, This is exactly what I expect the merge tool to look like. And #5770 should be implemented like this.

michaelKurowski commented 5 years ago

+1 it's the only feature that I'm really missing while using VSC in comparison to WebStorm.

danielnice commented 5 years ago

I would very much like this implemented as well, the only big whole I see in VS code as a full IDE

doub1ejack commented 5 years ago

Ok, since Webstorm seems to be the only real solution, I'm going to go download that now.
Really looking forward to VSCode supporting this feature!!

Also, could someone downvote this post for me? Thanks :P

bgarrant commented 5 years ago

Is this feature even in the works?

federicotomasi commented 5 years ago

+1, totally would use this if implemented

rebornix commented 5 years ago

I added a new setting and command to improve the merge conflict resolution a bit, here is what the experience will be after https://github.com/microsoft/vscode/pull/74231 is merged

Firstly a new setting merge-conflict.diffViewContext was added to show the context around the conflict

Before: there is no context around the diff compare-withoutcontext

After: with "merge-conflict.diffViewContext": 3 compare-with-context

Secondly, a new command Compare All is introduced to display the full compare between current workspace and incoming changes, with which you can compare the old content, the incoming one, and the latest local content on disk

compare-all

More work in the editor area needs to be done to support the JetBrains style, for example, opening a three column editor group from the conflict. But I still want to hear your feedback on the current solution mentioned above.

bgarrant commented 5 years ago

This is cool. Can you pick line by line what change you want to merged into the new file or is it just one file or the other? Line by line or All would be awesome!!!

bgarrant commented 5 years ago

If you can accept each change from either file block by block and merge into the third that would probably cover most use cases. So for example if one file had 3 changes and the other file had 4 I could chose whatever I wanted. Like accept 2 changes from one file and 2 changes from the other. Can it do this? If so...that rocks!

eamodio commented 5 years ago

@rebornix The additional context is nice, and I like the compare all, but for me there still a few things missing:

  1. Comparing each "side" with the common base -- while a 3-way merge view is probably best, this could at least help in the interim (I've been toying with adding something for this in GitLens)
  2. Being able to edit in the compare view and have the changes sync'd back to the document -- this is something that was talked about before better-merge was brought into the core. Here was a request about it (though the original request is gone :cry:) https://github.com/microsoft/vscode/issues/10547#issuecomment-300201327'

# 2 can probably be done today with a custom file system provider (though that feel like a lot of overkill)

rebornix commented 5 years ago

@eamodio

Comparing each "side" with the common base -- while a 3-way merge view is probably best, this could at least help in the interim (I've been toying with adding something for this in GitLens)

This one requires adding a new three way diff view (a three way diff algorithm and a three column editor) but it's doable. For # 2, I think a custom file system provider is the right way to go as the file content on disk contains merge conflicts (like >>>>>>, <<<<<<), while picking content changes from the diff view, we don't want to mess up with the file on disk, so it' a virtual file system provider already.

liushiqi9 commented 5 years ago

Need this feature very much.

andreiucm commented 5 years ago

@rebornix I like the idea I think it can be even better than open a 3 column editor since the laptop screens are not soo big. I think can be easier to improve it a bit to look finally like the Gitkracken merge tool showing the context on the top editor and allowing editing the reluting file (that currently has >>>><<<< ...) on the bottom.

merge-tool@2x
vedmant commented 5 years ago

Yeah, often when there is merge conflict I switch to PHPStorm, even if the other work on the project I do in VSCode. It's weird that two years passed and there is still no appropriate merger.

stephanmullerNL commented 5 years ago

@rebornix I like the idea I think it can be even better than open a 3 column editor since the laptop screens are not soo big. I think can be easier to improve it a bit to look finally like the Gitkracken merge tool showing the context on the top editor and allowing editing the reluting file (that currently has >>>><<<< ...) on the bottom.

I disagree, the three column layout is part of what makes the Webstorm one so great. It keeps a very neat overview

fabb commented 5 years ago

Same here, I always switch over to IntelliJ for merge conflict resolution. The „Resolve simple conflicts“ magic wand tool saves so much time too!

cailie commented 5 years ago

I change back to Visual Studio 2017 to resolve conflicts...

On Tue, Jun 25, 2019 at 8:35 AM fabb notifications@github.com wrote:

Same here, I always switch over to IntelliJ for merge conflict resolution. The „Resolve simple conflicts“ magic wand tool saves so much time too!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/microsoft/vscode/issues/37350?email_source=notifications&email_token=AAEN6O3LOPBVEY7PMABVNRDP4I3KZA5CNFSM4EBV5J4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYQUWAQ#issuecomment-505498370, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEN6O4AO24V4GB24EWOJGDP4I3KZANCNFSM4EBV5J4A .

SupinePandora43 commented 5 years ago

vscode must change git conflict tool, because while resolving conflicts vscode adds <<<, ===, which causes language syntax error

vedmant commented 5 years ago

@SupinePandora43 That's not VSCode, that's how git handles conflicts, it adds <<<, === to conflicting lines. WebStorm parses this blocks and creates great visual tool for merging.

SupinePandora43 commented 5 years ago

@vedmant then... vscode needs some parser

minkir014 commented 5 years ago

See here. Is that what you mean? https://github.com/Microsoft/vscode-tips-and-tricks/blob/master/media/resolve_merge_conflicts.gif

vedmant commented 5 years ago

@minkir014 Check attached image on original comment on top, this what everybody mean.

minkir014 commented 5 years ago

This is in vs code tips and tricks and that means it's built in vs code. So, why this issue is still opened?

Jackenmen commented 5 years ago

@minkir014 I'll link the image from original comment here again, cause you clearly are thinking about something different: https://user-images.githubusercontent.com/1470309/32250860-c677e4ce-bec0-11e7-82b5-0196d981cc28.png

vedmant commented 5 years ago

@minkir014 What's in VS code now is nothing near the feature IntelliJ has, just compare this: https://user-images.githubusercontent.com/1470309/32250860-c677e4ce-bec0-11e7-82b5-0196d981cc28.png and what you posted https://github.com/Microsoft/vscode-tips-and-tricks/blob/master/media/resolve_merge_conflicts.gif do you see much similarities?

Arelav commented 5 years ago

@minkir014 because built in feature it's not the same as we are discussing in this thread.