Skip to content

Commit

Permalink
Merge pull request #84 from Lymah123/merge-conflict
Browse files Browse the repository at this point in the history
 feat: adds a section about Merging Conflicts
  • Loading branch information
CBID2 authored Oct 25, 2023
2 parents 417e829 + e50244d commit efead39
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions 11-understanding-merge-conflicts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Understanding Merge Conflicts

- Merge conflicts happen when two branches have made different changes to the same lines in a file. Git cannot automatically determine which change to keep, and this results in a conflict.
- When a merge conflict occurs, Git adds special markers (<<<<<<<, =======, and >>>>>>) to the conflicted part of the file, indicating the conflicting sections from different branches.

## Resolving Merge Conflicts in VS Code

### Prerequisites:

Ensure you have Git and the GitLens extension installed in VS Code. GitLens is a powerful Git extension that enhances Git-related features in VS Code.

## Step-by-Step Guide

1. Open VS Code: Launch Visual Studio Code and open the repository where the merge conflict exists.
2. Check for Conflicts: If you've just performed a pull or merge operation and a conflict occurs, VS Code will automatically detect it.
You will see a notification in the source control tab or sidebar.
3. View Conflicted Files: Click on the conflicted file in the source control tab. VS Code will display a "Merge Conflict" section in the file.
4. Resolve Conflicts: Inside the "Merge Conflict" section, you'll see the conflicting changes separated by the conflict markers (<<<<<<<, =======, >>>>>>).
Manually edit the file to resolve the conflict. Decide which changes to keep or combine.
5. Save the file: After resolving the conflicts, save the file.
6. Stage the Resolved File: In the source control tab, you should see options to stage the resolved file. Click on the "Mark as Resolved" or similar button.
7. Commit the Changes: Once all conflicts are resolved, commit your changes using VS Code's built-in source control features.
8. Push Your Changes: After committing, push the changes to the remote repository to complete the merge process.
9. Verify the Merge: Verify that the merge conflict has been successfully resolved by checking the remote repository or using Git tools.

VS Code and GitLens simplify the conflict resolution process by providing a visual interface for managing merge conflicts. This allows you to easily navigate through conflicting files and review changes, making the process more intuitive.
1 change: 1 addition & 0 deletions _layouts/sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
- [Additional resources](/08-additional-resources.md)
- [Conclusion](/09-conclusion.md)
- [Glossary](/10-glossary.md)
- [Understanding merge conflicts](/11-understanding-merge-conflicts.md)

0 comments on commit efead39

Please sign in to comment.