Resolve Merge conflicts with confidence with GitLab Duo/AI
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Release notes
Problem to solve
Merge conflicts are a developer pain point to resolve. Different situations require different toolsets and often advanced developer experience.
- An MR was running stale, and GitLab UI in the MR says "Merge conflicts, resolve in the UI or locally"
- Problem: UI is confusing, or lacks the necessary insight of testing "which side wins for this specific change"
- An MR was running stale, and the conflicts could only be resolved locally.
- Requires: IDE that supports visual MR conflict resolving (and developers understanding it)
- Advanced knowledge on the terminal with Git CLI and vim/etc. to search for
<<<and edit which branch and change wins.
- A local merge conflict during Git rebase against a newer branch history.
- Which change wins?
- Maybe both changes are necessary to keep APIs and function calls intact?
- What is the full scope ... and what would break, if there are no compilation, (regression/production) tests after such a merge conflict resolval was conducted
Merge Conflicts generally block developers moving forward, and can influence release delays, missing documentation, etc.
Proposal
Resolving merge conflicts should be easier for developers and non-developers, such as contributors to documentation, handbook, CI/CD, translations, etc. Different UX paths are necessary for the GitLab UI, CLI, and IDEs.
- First iteration: GitLab detects a merge conflict. Next to regular UI options to resolve in UI or locally, there is a button with Fix with AI or so, which opens a Duo Chat prompt that explains the diff and proposes a fix.
- When permissions are granted, a second iteration can push a fix into the MR through Duo.
- 3rd iteration: Bring it to GitLab CLI, and IDE extensions.
- 4th iteration: Also support git rebase, which typically fails with merge conflicts for stale MRs.
This could be a use case for Duo Workflow on the platform because agents can fetch more contextual context (e.g., the Git history, software architecture requirements, or style guides).
Reproducible example
I asked GitLab Duo to create an example use case with diverging Git histories
Can you create a series of Git commands that simulate 2 branches, with a diverging git history, and creating a merge conflict failure with multiple changes that collide. This is for demoing purposes, use any simple code/markdown docs to illustrate the use case.
Generated Shell commands
# Create a new directory and initialize a Git repository
mkdir git-conflict-demo
cd git-conflict-demo
git init
# Create an initial README.md file with some content
cat > README.md << 'EOF'
# Project Documentation
## Introduction
This is a sample project to demonstrate Git features.
## Features
- Feature A: Basic functionality
- Feature B: Advanced options
- Feature C: Integration capabilities
## Installation
Run `npm install` to install dependencies.
## Usage
See the examples in the `/examples` directory.
EOF
# Initial commit
git add README.md
git commit -m "Initial commit with project documentation"
# Create a new file that will also have conflicts
cat > contributors.md << 'EOF'
# Contributors
## Core Team
- Alice Smith (Project Lead)
- Bob Johnson (Developer)
- Carol Williams (Designer)
## Community Contributors
- David Brown
- Emma Davis
EOF
git add contributors.md
git commit -m "Add contributors list"
# Create and switch to feature branch
git checkout -b feature-update
# Make changes on the feature branch
cat > README.md << 'EOF'
# Enhanced Project Documentation
## Introduction
This is a comprehensive project demonstrating advanced Git workflows.
## Key Features
- Feature A: Basic functionality with improved performance
- Feature B: Advanced options with new configuration settings
- Feature C: Integration capabilities with third-party systems
- Feature D: New analytics dashboard
- Feature E: User management system
## Installation
Run `npm install --production` for minimal installation.
For development, use `npm install --dev`.
## Usage
See the detailed examples in the `/examples` directory.
Check our documentation site at https://example.com/docs.
EOF
# Update contributors file on feature branch
cat > contributors.md << 'EOF'
# Project Contributors
## Core Team
- Alice Smith (Project Lead & Architect)
- Bob Johnson (Senior Developer)
- Carol Williams (UX Designer)
- Frank Miller (DevOps Engineer)
## Community Contributors
- David Brown
- Emma Davis
- George Wilson
- Hannah Martinez
EOF
git add README.md contributors.md
git commit -m "Enhance documentation and update contributors list"
# Add another file on feature branch
cat > roadmap.md << 'EOF'
# Project Roadmap
## Q3 2023
- Improve performance
- Add new analytics features
## Q4 2023
- User management system
- API enhancements
EOF
git add roadmap.md
git commit -m "Add project roadmap"
# Switch back to main branch
git checkout main
# Make different changes to the same files on main
cat > README.md << 'EOF'
# Project Documentation
## Introduction
This is a sample project to demonstrate Git features and best practices.
## Features
- Feature A: Basic functionality
- Feature B: Advanced options
- Feature C: Integration capabilities
- Feature X: Security enhancements
- Feature Y: Performance optimizations
## Installation
Run `npm install` to install dependencies.
For Docker users: `docker-compose up -d`.
## Configuration
Copy `config.example.json` to `config.json` and edit as needed.
## Usage
See the examples in the `/examples` directory.
EOF
# Update contributors file on main branch differently
cat > contributors.md << 'EOF'
# Contributors
## Core Team
- Alice Smith (Project Lead)
- Bob Johnson (Developer)
- Carol Williams (Designer)
- Eve Taylor (QA Engineer)
## Community Contributors
- David Brown (Documentation)
- Emma Davis (Testing)
- Michael Lee (Security)
EOF
git add README.md contributors.md
git commit -m "Update documentation and add team members"
# Add a different file on main
cat > SECURITY.md << 'EOF'
# Security Policy
## Reporting a Vulnerability
Please report security vulnerabilities to security@example.com.
## Supported Versions
| Version | Supported |
| ------- | ------------------ |
| 1.1.x | :white_check_mark: |
| 1.0.x | :x: |
EOF
git add SECURITY.md
git commit -m "Add security policy"
# Now try to merge feature-update into main (this will cause conflicts)
echo "Now attempting to merge feature-update into main (will cause conflicts)..."
git merge feature-update
Shell commands output
Initialized empty Git repository in /Users/mfriedrich/dev/work/ai/conflicts/git-conflict-demo/.git/
[main (root-commit) aa6e0d7] Initial commit with project documentation
1 file changed, 15 insertions(+)
create mode 100644 README.md
[main 0315239] Add contributors list
1 file changed, 10 insertions(+)
create mode 100644 contributors.md
Switched to a new branch 'feature-update'
[feature-update 70edf8a] Enhance documentation and update contributors list
2 files changed, 19 insertions(+), 12 deletions(-)
[feature-update 9b8e865] Add project roadmap
1 file changed, 9 insertions(+)
create mode 100644 roadmap.md
Switched to branch 'main'
[main a41bdb8] Update documentation and add team members
2 files changed, 11 insertions(+), 3 deletions(-)
[main 8327d5f] Add security policy
1 file changed, 10 insertions(+)
create mode 100644 SECURITY.md
Now attempting to merge feature-update into main (will cause conflicts)...
Auto-merging README.md
CONFLICT (content): Merge conflict in README.md
Auto-merging contributors.md
CONFLICT (content): Merge conflict in contributors.md
Automatic merge failed; fix conflicts and then commit the result.
diff --cc README.md
index a01bae4,bd91a10..0000000
--- a/README.md
+++ b/README.md
@@@ -1,21 -1,19 +1,37 @@@
- # Project Documentation
+ # Enhanced Project Documentation
## Introduction
++<<<<<<< HEAD
+This is a sample project to demonstrate Git features and best practices.
+
+## Features
+- Feature A: Basic functionality
+- Feature B: Advanced options
+- Feature C: Integration capabilities
+- Feature X: Security enhancements
+- Feature Y: Performance optimizations
+
+## Installation
+Run `npm install` to install dependencies.
+For Docker users: `docker-compose up -d`.
+
+## Configuration
+Copy `config.example.json` to `config.json` and edit as needed.
++=======
+ This is a comprehensive project demonstrating advanced Git workflows.
+
+ ## Key Features
+ - Feature A: Basic functionality with improved performance
+ - Feature B: Advanced options with new configuration settings
+ - Feature C: Integration capabilities with third-party systems
+ - Feature D: New analytics dashboard
+ - Feature E: User management system
+
+ ## Installation
+ Run `npm install --production` for minimal installation.
+ For development, use `npm install --dev`.
++>>>>>>> feature-update
## Usage
- See the examples in the `/examples` directory.
+ See the detailed examples in the `/examples` directory.
+ Check our documentation site at https://example.com/docs.
diff --cc contributors.md
index 5adc4c3,c93d311..0000000
--- a/contributors.md
+++ b/contributors.md
@@@ -1,12 -1,13 +1,25 @@@
- # Contributors
+ # Project Contributors
## Core Team
++<<<<<<< HEAD
+- Alice Smith (Project Lead)
+- Bob Johnson (Developer)
+- Carol Williams (Designer)
+- Eve Taylor (QA Engineer)
+
+## Community Contributors
+- David Brown (Documentation)
+- Emma Davis (Testing)
+- Michael Lee (Security)
++=======
+ - Alice Smith (Project Lead & Architect)
+ - Bob Johnson (Senior Developer)
+ - Carol Williams (UX Designer)
+ - Frank Miller (DevOps Engineer)
+
+ ## Community Contributors
+ - David Brown
+ - Emma Davis
+ - George Wilson
+ - Hannah Martinez
++>>>>>>> feature-update
Intended users
- Sasha (Software Developer)
- Priyanka (Platform Engineer)
- Sidney (Systems Administrator)
- Simone (Software Engineer in Test)
- Eddie (Content Editor)
- Amy (Application Security Engineer)
- Isaac (Infrastructure Engineer)