Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git: Use VS Code as merge editor #5770

Closed
nchammas opened this issue Apr 25, 2016 · 116 comments
Closed

Git: Use VS Code as merge editor #5770

nchammas opened this issue Apr 25, 2016 · 116 comments
Assignees
Labels
feature-request Request for new features or functionality git GIT issues merge-editor merge-editor-workbench on-testplan
Milestone

Comments

@nchammas
Copy link

1.0.0 introduced the ability to use VS Code as a git difftool. The relevant global .gitconfig lines are as follows:

[diff]
    tool = default-difftool
[difftool "default-difftool"]
    cmd = code --wait --diff $LOCAL $REMOTE

How can I use VS Code as a git mergetool?

The relevant arguments it needs to accept, I believe, are $LOCAL, $REMOTE, $BASE, and $MERGED.

@bpasero bpasero added feature-request Request for new features or functionality git GIT issues labels Apr 26, 2016
@joaomoreno
Copy link
Member

Not supported yet.

@joaomoreno joaomoreno removed their assignment Apr 26, 2016
@skijit
Copy link

skijit commented May 4, 2016

Is this feature being included in the next iteration, by any chance?

@joaomoreno
Copy link
Member

Probably not, this is a big endeavour, since a merge UI needs to be implemented.

@ZombieProtectionAgency
Copy link

Is there any plan for the merge UI to support three-way merging? (e.g. change a, change b, common ancestor)

@joaomoreno
Copy link
Member

We wouldn't have it any other way. 😉

@theoy
Copy link

theoy commented Aug 8, 2016

Can't upvote this one enough. This is the top scenario for me to fall back to a different editor/IDE (*cough* memory-hog Webstorm cough) :)

@kumarharsh
Copy link
Contributor

If possible, this would be a godsend, due to several reasons:

  1. Meld, although functional, severely lacks in functionality in relation to configurable key-bindings and colour highlighting, and is really really slow to start on my Windows machine, even when installed on an SSD.
  2. I'd like the merge editor to also accept the same .editorconfig/settings which my main text editor has, and if vscode does fill that gap, it'd be awesome.
  3. On smaller levels, the editor theme and familiarity with the interface is also a plus - sometimes I or my team makes mistakes while merging due to no syntax highlighting, which although small, have caused huge bugs in production systems. And some of those mistakes are rather difficult to even fathom until they occur. I guess there would always be similar problems with mergetools, but perhaps they will be reduced if one could merge in the same environment in which one writes.

Like I said, meld is ok, but it'd be super if vscode would some day be used in that scenario.

@egucciar
Copy link

Visual Studio was always my code merger of choice. Would love to see this feature!

@cchitsiang
Copy link

No problem on using other git mergetool but really would like to see own merge UI happen really soon!!

@eckdanny
Copy link

eckdanny commented Dec 2, 2016

😐 meh.

I expect these features in heavy weight IDEs. In vscode's class of light weight editors (in which I'd consider atom, sublime, etc) I don't. For git-related activities I favor a terminal and vim for conflict resolution. The GUI crowd already has great uni-taskers like meld, diffmerge, kaleidoscope, etc.

@kumarharsh that's a good point about immediate feedback (e.g.; linting.) Going the vim route above, I suppose you can set git's default external editor to vscode... tho could be a pain to provide context to the project-specific linting/syntax/etc rules.

@herbertpimentel
Copy link

+1

@ghost
Copy link

ghost commented Dec 7, 2016

can this feature be implemented as an extension of vscode? or any exists ext recommended.

@herbertpimentel
Copy link

herbertpimentel commented Dec 7, 2016 via email

@kumarharsh
Copy link
Contributor

The plugin can provide UI features: look at Git History. It renders a webview, which can "potentially" be used as a merge-tool. But I think it'll be very hard for a plugin to do it without some level of support by vscode itself.

@josser
Copy link

josser commented Dec 7, 2016

Main issue with kaleidoscope, meld, etc tools is in very typical use-case:
Edit result during merge. Like, you know: accept this line from the left, accept that line from the right, and also, add this small fix so they both can work together.
Captain obvious is reporting: Merge tools are good in merging :D
But editing using i.e meld is totally pain especially when you are get used to such handy tool as vscode. That's why most developers want merge-tool integrated in their editor.

@jayshah123
Copy link

P4merge's 4-pane 3-way merge UI is excellent.
http://naleid.com/blog/2013/10/29/how-to-use-p4merge-as-a-3-way-merge-tool-with-git-and-tower-dot-app

@idibidiart
Copy link

allowing us to see the diff (incredibly useful features in an editor) but not giving us a way to merge is very underwhelming

@MarvDann
Copy link

A VS Code extension would be perfect for merging conflicts.

@bogminic
Copy link

bogminic commented Mar 2, 2017

+1

@vidhya03
Copy link

Git side by side conflict resolver not working in latest VS code.

Version 1.10.2
Commit 8076a19
Date 2017-03-08T14:02:52.799Z
Shell 1.4.6
Renderer 53.0.2785.143
Node 6.5.0

@tolgabalci
Copy link

Would really like to be able to edit code while merging while using my code editor (vscode), rather than having to use some other editor.

@trumbitta
Copy link

Three-way merging / diffing is the way to go for sure

@raxetul
Copy link

raxetul commented Apr 2, 2021

The missing point is that we don't have 3 or 5 line conflicts. Current inline diffs are not practical for conflicts with over 20 lines even we have 2K and 4K monitors. Also, it would be great to have the ability to mark reviewed diffs not to check again and again.

@lig
Copy link

lig commented Jul 8, 2022

So, the feature is there starting from 1.69. However, I haven't figured out yet how to open the three-way merge from command line that is required for using it as a true git mergetool.

For the difftool I use code --wait --reuse-window --diff $LOCAL $REMOTE.

@bpasero bpasero self-assigned this Jul 8, 2022
bpasero added a commit that referenced this issue Jul 18, 2022
* introduce `--merge` to bring up merge editor (for #5770)

* wait on proper editor when merging

* sqlite slowness

* disable flush on write in tests unless disk tests

* more runWithFakedTimers

* disable flush also in pfs

* introduce `IResourceMergeEditorInput`

* cleanup

* align with merge editor names

* stronger check

* adopt `ResourceSet`

* no need to coalesce

* improve `matches` method
@bpasero
Copy link
Member

bpasero commented Jul 19, 2022

Landed in todays insider as:

-m --merge <path1> <path2> <base> <result> Perform a three-way merge by providing paths for two modified versions of a file, the common origin of both modified versions and the output file to save merge results

In order to use it for git, you also need to add the --wait parameter, e.g.

[merge]
	tool = code-insiders
[mergetool]
	writeToTemp = true
	keepBackup = false
[mergetool "code-insiders"]
	cmd = code-insiders --wait -m $REMOTE $LOCAL $BASE $MERGED

You can give our preview releases a try from: https://code.visualstudio.com/insiders/

I suggest to open new issues for issues found and close this one. One feature request on my backlog is to allow to provide labels for the $REMOTE and $LOCAL version to better identify both sides. If someone knows if Git provides good names with some trick or script, please let me know.

@bpasero bpasero closed this as completed Jul 19, 2022
@ghost
Copy link

ghost commented Jul 19, 2022

@bpasero i tested it . looks good for me .

@ghost
Copy link

ghost commented Jul 19, 2022

image
How ever, it need more tune.
Like quick accept code block , by select left or right

@bpasero
Copy link
Member

bpasero commented Jul 19, 2022

Same as for the CLI support, feedback for the merge editor should be reported as individual issues.

@jrieken
Copy link
Member

jrieken commented Jul 19, 2022

As @bpasero said: new, separate issues please! Before that consult the list of remaining bugs and feature-requests: merge-editor

@github-actions github-actions bot locked and limited conversation to collaborators Sep 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality git GIT issues merge-editor merge-editor-workbench on-testplan
Projects
None yet
Development

No branches or pull requests