[git] Visual Studio Code how to resolve merge conflicts with git?

I tried to merge my branch with another branch and there was a merge conflict. In Visual Studio Code (version 1.2.1) I resolved all of the issues, however when I try to commit it keeps giving me this message:

You should first resolve the un-merged changes before committing your changes.

I've tried googling it but I can't find out why it won't let me commit my changes, all of the conflicts have disappeared.

This question is related to git visual-studio merge visual-studio-code

The answer is

With VSCode you can find the merge conflicts easily with the following UI. enter image description here

(if you do not have the topbar, set "editor.codeLens": true in User Preferences)

It indicates the current change that you have and incoming change from the server. This makes it easy to resolve the conflicts - just press the buttons above <<<< HEAD.

If you have multiple changes and want to apply all of them at once - open command palette (View -> Command Palette) and start typing merge - multiple options will appear including Merge Conflict: Accept Incoming, etc.

For those who are having a hard time finding the "merge buttons".

The little lightbulp icon with merge options only shows up if you click precisely on the "merge conflict marker"


Steps (in VS Code 1.29.x):

  1. Click "Source Control" button on left.
  2. See MERGE CHANGES in sidebar.
  3. Those files have merge conflicts.

VS Code > Source Control > Merge Changes (Example)

The error message you are getting is a result of Git still thinking that you have not resolved the merge conflicts. In fact, you already have, but you need to tell Git that you have done this by adding the resolved files to the index.

This has the side effect that you could actually just add the files without resolving the conflicts, and Git would still think that you have. So you should be diligent in making sure that you have really resolved the conflicts. You could even run the build and test the code before you commit.

For VS Code 1.38 or if you could not find any "lightbulb" button. Pay close attention to the greyed out text above the conflicts; there is a list of actions you can take.

Questions with git tag:

Does the target directory for a git clone have to match the repo name? Git fatal: protocol 'https' is not supported Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) git clone: Authentication failed for <URL> destination path already exists and is not an empty directory SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 GitLab remote: HTTP Basic: Access denied and fatal Authentication How can I switch to another branch in git? VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio? How to know the git username and email saved during configuration? How to add a new project to Github using VS Code git clone error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054 fatal: ambiguous argument 'origin': unknown revision or path not in the working tree HTTP Basic: Access denied fatal: Authentication failed npm notice created a lockfile as package-lock.json. You should commit this file Do I commit the package-lock.json file created by npm 5? Abort a Git Merge key_load_public: invalid format git - remote add origin vs remote set-url origin Visual Studio 2017 - Git failed with a fatal error Get git branch name in Jenkins Pipeline/Jenkinsfile Changing the git user inside Visual Studio Code How to compare different branches in Visual Studio Code Git checkout - switching back to HEAD Clear git local cache Deleting a local branch with Git Rebuild Docker container on file changes Cloning specific branch How to add chmod permissions to file in Git? Git copy changes from one branch to another Git merge with force overwrite Project vs Repository in GitHub How to add a file to the last commit in git? Getting permission denied (public key) on gitlab Delete commit on gitlab gpg failed to sign the data fatal: failed to write commit object [Git 2.10.0] Remove a modified file from pull request Updates were rejected because the tip of your current branch is behind its remote counterpart Can't push to the heroku How to discard local changes and pull latest from GitHub repository In Visual Studio Code How do I merge between two local branches? error: RPC failed; curl transfer closed with outstanding read data remaining Change drive in git bash for windows Checkout Jenkins Pipeline Git SCM with credentials? How to fix git error: RPC failed; curl 56 GnuTLS Trying to pull files from my Github repository: "refusing to merge unrelated histories" Visual Studio Code how to resolve merge conflicts with git? merge one local branch into another local branch Can't push to remote branch, cannot be resolved to branch

Questions with visual-studio tag:

VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio? How to download Visual Studio Community Edition 2015 (not 2017) Cannot open include file: 'stdio.h' - Visual Studio Community 2017 - C++ Error How to fix the error "Windows SDK version 8.1" was not found? Visual Studio Code pylint: Unable to import 'protorpc' Open the terminal in visual studio? Is Visual Studio Community a 30 day trial? How can I run NUnit tests in Visual Studio 2017? Visual Studio 2017: Display method references Visual Studio 2017 errors on standard headers Where is NuGet.Config file located in Visual Studio project? Visual Studio 2017 error: Unable to start program, An operation is not legal in the current state Visual Studio 2017 - Git failed with a fatal error Unity Scripts edited in Visual studio don't provide autocomplete Equivalent to AssemblyInfo in dotnet core/csproj How to enable C++17 compiling in Visual Studio? Nuget connection attempt failed "Unable to load the service index for source" Change language of Visual Studio 2017 RC Could not load file or assembly 'Newtonsoft.Json, Version=, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies Visual Studio Code how to resolve merge conflicts with git? Getting "project" nuget configuration is invalid error "Object doesn't support property or method 'find'" in IE localhost refused to connect Error in visual studio Why is the Visual Studio 2015/2017/2019 Test Runner not discovering my xUnit v2 tests Build error, This project references NuGet Visual Studio Code always asking for git credentials Stuck while installing Visual Studio 2015 (Update for Microsoft Windows (KB2999226)) Visual Studio error "Object reference not set to an instance of an object" after install of ASP.NET and Web Tools 2015 C# - How to convert string to char? Multiple Errors Installing Visual Studio 2015 Community Edition Why Visual Studio 2015 can't run exe file (ucrtbased.dll)? Where can I read the Console output in Visual Studio 2015 Go To Definition: "Cannot navigate to the symbol under the caret." CMake error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found How to remove error about glyphicons-halflings-regular.woff2 not found NuGet Packages are missing Visual Studio Community 2015 expiration date How to solve ERR_CONNECTION_REFUSED when trying to connect to localhost running IISExpress - Error 502 (Cannot debug from Visual Studio)? Where is the visual studio HTML Designer? error C4996: 'scanf': This function or variable may be unsafe in c programming What are the differences between Visual Studio Code and Visual Studio? Is Xamarin free in Visual Studio 2015? What's the difference between Visual Studio Community and other, paid versions? Visual Studio 2015 installer hangs during install? How to use class from other files in C# with visual studio? 'cannot find or open the pdb file' Visual Studio C++ 2013 How to build x86 and/or x64 on Windows from command line with CMAKE? Python Pip install Error: Unable to find vcvarsall.bat. Tried all solutions How to enable C# 6.0 feature in Visual Studio 2013?

Questions with merge tag:

Pandas Merging 101 Python: pandas merge multiple dataframes Git merge with force overwrite Merge two dataframes by index Visual Studio Code how to resolve merge conflicts with git? merge one local branch into another local branch Merging dataframes on index with pandas Git merge is not possible because I have unmerged files Git merge develop into feature branch outputs "Already up-to-date" while it's not How merge two objects array in angularjs? Merge r brings error "'by' must specify uniquely valid columns" How to unmerge a Git merge? Merge two Excel tables Based on matching data in Columns What is the precise meaning of "ours" and "theirs" in git? How do I concatenate or merge arrays in Swift? Git merge two local branches git: updates were rejected because the remote contains work that you do not have locally Left join only selected columns in R with the merge() function pandas three-way joining multiple dataframes on columns Detect merged cells in VBA Excel with MergeArea Pandas left outer join multiple dataframes on multiple columns Git diff between current branch and master but not including unmerged master commits How to append rows to an R data frame Combine two pandas Data Frames (join on a common column) Eclipse EGit Checkout conflict with files: - EGit doesn't want to continue Python Pandas merge only certain columns The following untracked working tree files would be overwritten by merge, but I don't care Moving Git repository content to another repository preserving history What's the difference between 'git merge' and 'git rebase'? Merging two CSV files using Python Apply pandas function to column to create multiple new columns? Why does Git say my master branch is "already up to date" even though it is not? Git - Ignore files during merge Merging a lot of data.frames What to do with branch after merge How can I combine two commits into one commit? implementing merge sort in C++ How to merge multiple lists into one list in python? How do I merge changes to a single file, rather than merging commits? Merge DLL into EXE? Get value of a merged cell of an excel from its cell address in vba git cherry-pick says "...38c74d is a merge but no -m option was given" What is the difference between `git merge` and `git merge --no-ff`? Gerrit error when Change-Id in commit messages are missing Simultaneously merge multiple data.frames in a list Merge data frames based on rownames in R Merge a Branch into Trunk How do you rebase the current branch's changes on top of changes being merged in? What's a good (free) visual merge tool for Git? (on windows) How do I combine two data-frames based on two columns?

Questions with visual-studio-code tag:

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined raised when starting react app Visual Studio Code PHP Intelephense Keep Showing Not Necessary Error Cannot edit in read-only editor VS Code How to setup virtual environment for Python in VS Code? Pylint "unresolved import" error in Visual Studio Code Why do I keep getting Delete 'cr' [prettier/prettier]? How to set up devices for VS Code for a Flutter emulator VSCode single to double quote automatic replace js 'types' can only be used in a .ts file - Visual Studio Code using @ts-check How can I clear the terminal in Visual Studio Code? Is there any way to set environment variables in Visual Studio Code? How to connect TFS in Visual Studio code How to shift a block of code left/right by one space in VSCode? How to add a new project to Github using VS Code Is there a way to remove unused imports and declarations from Angular 2+? How to create a Java / Maven project that works in Visual Studio Code? Select all occurrences of selected word in VSCode How to see local history changes in Visual Studio Code? VSCode cannot find module '@angular/core' or any other modules #include errors detected in vscode ESLint not working in VS Code? Visual Studio Code - Target of URI doesn't exist 'package:flutter/material.dart' What is a 'workspace' in Visual Studio Code? VSCode Change Default Terminal Visual Studio Code Search and Replace with Regular Expressions Visual Studio Code open tab in new window Activating Anaconda Environment in VsCode Error message "Linter pylint is not installed" Switch focus between editor and integrated terminal in Visual Studio Code Collapse all methods in Visual Studio Code How do I use Bash on Windows from the Visual Studio Code integrated terminal? Changing the git user inside Visual Studio Code Color theme for VS Code integrated terminal How to compare different branches in Visual Studio Code How to restart VScode after editing extension's config? Moving Panel in Visual Studio Code to right side Restore a deleted file in the Visual Studio Code Recycle Bin VSCode: How to Split Editor Vertically Install a Nuget package in Visual Studio Code How to indent/format a selection of code in Visual Studio Code with Ctrl + Shift + F How to change the integrated terminal in visual studio code or VSCode PHP executable not found. Install PHP 7 and add it to your PATH or set the php.executablePath setting How to do tag wrapping in VS code? Debug/run standard java in Visual Studio Code IDE and OS X? Visual Studio Code: How to show line endings How do you format code on save in VS Code Is there a quick change tabs function in Visual Studio Code? Duplicate line in Visual Studio Code Open files always in a new tab In Visual Studio Code How do I merge between two local branches?