Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code doesn't stage Git merge changes

Using Git as a source control provider in Visual Studio Code I have an issue whenever I try to merge a conflict file with remote repository keeping my current version.

The steps are the following:

  • A file has been modified on remote repository and I modify the same file on the local repository
  • When I try to push my changes to the server I recieve (correctly) an error message (no-fast-forward) and I must perform a pull to update my local repository
  • When pulling, the editor warn me about the conflict on the file, giving me four option (Accept Current Change, Accept Incoming Change, Accept Both Changes, Compare Changes)
  • I accept the current change (my local version) and save the file. When I try to stage the change the file is not added to the section STAGED CHANGES but it disappears. Git remain in a "merging" status and I can't do anything (a push gives me the same error of the first push and a pull gives me an error like I didn't resolved the conflict; in fact in the .git folder I still have the MERGE_HEAD file)

If I Accept the Incoming Change, Accept Both Changes or add additional chars to my previous version (to change the version I tried to commit before) everything works fine. I think that when I choose "Accept Current Change" and try to stage merge changes the editor (or Git?) doesn't add the file to the STAGED CHANGES because it's identical to the version previously committed, and doesn't update the git status, that remains stuck in merge conflict.

The workaround of adding additional chars to the previous version when merging works fine, but I need to know if it's a bug or I'm missing some steps when merging.

Please don't reply me with command line workaround (like git merge --abort), I'm looking for a UI friendly solution (not all of my team mates are confident with command line). Thanks in advance.

like image 535
Matteo Boscarino Avatar asked Oct 05 '18 08:10

Matteo Boscarino


People also ask

How do you stage change in VSCode?

To stage changes when you're ready, select the + (plus) button on each file you want to stage, or right-click a file and then select Stage. You can also stage all your modified files with one click by using the stage all + (plus) button at the top of the Changes section.

How do I merge changes in git Visual Studio?

To merge commits in Visual Studio, use the Ctrl key to select multiple commits that you want to merge. Then right-click and select Squash Commits. Visual Studio automatically combines your commit messages, but sometimes it's better to provide an updated message.

How do I see git changes in Visual Studio Code?

When you have repository open in Visual Studio code, you can execute the command Git: View History (git log) from the command Plate. This will open the Git History Window with all change logs for the repository. You can then select individual commits for detailed change logs for each of them.


1 Answers

This was a bug in Visual Studio Code which has been fixed in commit 578d7381da3e9d559e9326375b67429a5de3027d and was shipped in November 2020 with version 1.52.0 of VS Code.

like image 187
knittl Avatar answered Sep 29 '22 11:09

knittl