How to properly handle merges when running GIT PULL in Visual Studio

I cannot do GIT for TFS to work correctly in Visual Studio when working with merges. Basically, all the merge operations that occur when I pull the latest version of the code are a nightmare.

I specifically talk about merges that occur when they pull the code of another from the same branch (i.e. I'm not talking about scripts involving multiple branches).

I also specifically talk about the built-in GIT plugin of Visual Studio , so please do not offer to execute command line commands that I know about (for example, rebase) if there is another solution from the IDE ("you cannot" would be the correct answer).

Here's how to reproduce the problem:

  • There are two developers: A and B, working on the same branch.
  • developer A pushes some commit that modifies files F1 and F2
  • Developer B modifies files F1 and F3
  • Developer B makes modifications to F1 and F3
  • Developer B makes an attempt: Visual Studio detects a conflict in the F1 file (which is expected)
  • Developer B resolves conflict in F1

Now here is the problem: all files F1, F2 and F3 are in a modified state for B. Why? Developer B only modified the F1 and F3 files. I see no real reason for F2 to be in a modified state , because B did not change it.

I understand that locally the F2 file does not match the previous one, but the problem is that B basically cannot view its changes on F1 and F3 before pressing, because all the others work (in the simplified case above, on F2) also appears in his list of changes.

In our real-world scenarios, there are several developers working in the same industry, and each merge is one of the main failures in the history of the industry: Visual Studio basically shows a bunch of 50-or-so modified files for each merge (when the developer only modified 1 or 2 files).

This problem always occurs with updated Visual Studio 2013. Visual Studio 2015 seems smart enough not to show F2 as changed, but not always.

How to fix this behavior? GIT is currently PITA for use in Visual Studio because of this.


EDIT:

Here is a visual example. On the left is the story, as shown in VS 2013: a lot of modified files. On the right is the same story (the same repository, the same machine, the same commit ... etc.), as shown in VS 2015. Obviously, VS 2015 shows something different and a little better (I see only my changes). Note that this is not always the case, sometimes VS 2015 shows files that I did not modify, like VS 2013.

This question dealt with this behavior when I am about to push the result of a merge, but it is exactly the same when I just look at the history of the old merge as shown below:

enter image description here

Questions:

  • This is mistake?
  • If not, is this documented?
  • anyway, how should I work with GIT, especially with VS 2013, regarding inconsistency, as shown above?
+5
source share
2 answers

You only need to understand how git works.

When you speak:

Developer B makes an attempt: Visual Studio detects a conflict in the F1 file (which is expected)

What are you mistaken. git detects conflicts and therefore cannot merge. (Even if you merge with the "same" branch, what git does is create a merge commit to stick these branches together).

When this happens, git shows you all the differences caused by both branches. You can git add (or anything that it invoked in visual studio) all files without conflict, they will be part of the "merge".

The only thing you need to do is fix the conflicts in which they are marked, and leave the rest, but as it is, and create a merge fix.

To summarize when a merge fails, you can see both changes and conflicts. Just focus on resolving conflicts and let regular changes be what they are.

+2
source

I used Visual studio 2013 with Git and it works great for the script mentioned above.

What I can offer is to check if there is a difference in the user settings of these developers. Any change in line outlines, tab area, or using Ctrl + K + F (shortcut formatting) can be a problem.

What I propose to remove any custom plugin, in addition to self-supporting VS, update Visual Studio to the latest patch.

If the problems still persist, try importing the same user settings for all Visual Studio developers. See How to use general settings between computers or versions of Visual Studio.

Tools => Import and Export Settings .. =>

enter image description here

Next => enter image description here

Export this parameter and import it to all other users so that all users have the same settings.

Various plugins, such as the Git Extension, the tortoise Git or any other custom Git extension, can play with line endings or default space tabs, which leads to changes found in almost all modified files of any developer.

0
source

Source: https://habr.com/ru/post/1245981/


All Articles