Note: this article is published on 06/03/2024.
A - Introduction
When a team works against a repository, team members work parallelly with the same file. When a member merges the change back to master or merges to other branches, the file is changed by more than one user could cause conflict that the merger has to handle. Sometimes, when one user makes the merge, when conflict, he/she does not want to use other changes, just want to keep what he/she has. This article will discuss this issue.
This is the solution from Git Document

This is an implementation from GitHub [ref] for Git envieonment. This article will demostrate the same procedure in Visual Studio environment.
- A - Introduction
- B - Setup Project and Branches
- C - Problem: Merge with Conflict
- D - Solution
- D-1 - Add a .gitattributes File in the Merged Branch
- D-2 - Setup the Environment
- E - Demo
B - Setup Project and Branches:
Create a project with one file: index.txt

write context into the file: "Base", save to master Branch:

Based on master Branch, create a new Branch: A, and add "+A" into the index.txt file:

Based on master Branch, create a new Branch: B, and add "+B" into the index.txt file:

Based on master Branch, create a new Branch: C, and add "+C" into the index.txt file:

C - Problem: Merge with Conflict
Merge A to B:

we got conflict:

The conflict:












Join the conversation! Your thoughts help the community grow.