Replit includes a Git pane (Tools -> Git) for visual version control and a full Git CLI in Shell. When merge conflicts occur during a pull, Replit highlights the conflict markers in the editor so you can manually resolve them. This tutorial covers how to use both the Git pane and Shell to handle conflicts, including understanding conflict markers, choosing which changes to keep, and completing the merge with a clean commit.
Fix Git Merge Conflicts in Replit Using the Git Pane and Shell
Merge conflicts happen when two branches change the same lines of code and Git cannot automatically combine them. In Replit, conflicts show up when you pull from GitHub or merge branches. The Git pane highlights conflicted files, and the editor displays conflict markers that you resolve manually. This tutorial explains what conflict markers mean, how to resolve them in both the visual Git pane and the Shell, and how to complete the merge cleanly.
Prerequisites
- A Replit account with a project connected to GitHub
- Basic understanding of Git concepts (commit, branch, push, pull)
- A GitHub account connected to Replit (Settings -> Connectors -> GitHub)
- Familiarity with the Replit workspace (editor, Shell, Tools panel)
Step-by-step guide
Understand when and why merge conflicts occur
Understand when and why merge conflicts occur
A merge conflict happens when two people (or two branches) modify the same lines of code and Git cannot determine which version to keep. In Replit, this most commonly occurs when you pull from GitHub after someone else has pushed changes that overlap with your local edits. It also happens when Agent creates changes on a branch while you are working on the same files. When a conflict is detected, Replit will not complete the pull automatically. Instead, it marks the conflicted files and waits for you to resolve them manually.
Expected result: You understand that merge conflicts are normal and happen when overlapping changes need human decision-making.
Identify conflicted files in the Git pane
Identify conflicted files in the Git pane
Open the Git pane by clicking Tools in the left sidebar and selecting Git. When conflicts exist, you will see conflicted files listed with a warning indicator. Click on a conflicted file to open it in the editor. Replit highlights the conflict markers so they are visually distinct from normal code. The markers divide the file into sections: your local changes versus the incoming changes from the remote branch. Each conflict region starts with <<<<<<< and ends with >>>>>>>.
Expected result: The Git pane shows conflicted files and the editor displays highlighted conflict markers when you open one.
Read and resolve conflict markers in the editor
Read and resolve conflict markers in the editor
Conflict markers have three parts. The section between <<<<<<< HEAD and ======= contains your local changes. The section between ======= and >>>>>>> contains the incoming changes from the remote branch. To resolve the conflict, decide which version to keep: your changes, the incoming changes, or a combination of both. Delete the conflict markers (the <<<<<<< HEAD, =======, and >>>>>>> lines) and leave only the code you want to keep. Save the file after resolving each conflict.
1<<<<<<< HEAD2// Your local version3const greeting = 'Hello, World!';4=======5// Incoming version from GitHub6const greeting = 'Hi there!';7>>>>>>> origin/main89// After resolving — keep the version you want:10const greeting = 'Hello, World!';Expected result: The conflict markers are removed and the file contains only the code you want to keep.
Use Shell for more control over conflict resolution
Use Shell for more control over conflict resolution
For complex conflicts or multiple files, Shell gives you more control. Run git status to see all conflicted files. Open each file, resolve the markers, then run git add filename to mark it as resolved. After resolving all files, run git commit to complete the merge. If you want to abort the merge entirely and go back to your pre-merge state, run git merge --abort. Shell commands give you the full power of Git, including the ability to use git diff to see exactly what changed.
1# See all conflicted files2git status34# After resolving conflicts in a file, stage it5git add src/App.tsx67# Check remaining conflicts8git diff --name-only --diff-filter=U910# After all files are resolved, complete the merge11git commit -m "Resolved merge conflicts with origin/main"1213# If you want to abort and try again14git merge --abortExpected result: All conflicts are resolved, staged, and committed. Running git status shows a clean working tree.
Push the resolved merge back to GitHub
Push the resolved merge back to GitHub
After completing the merge commit, push your changes to GitHub using the Git pane (click the Push button) or Shell (git push). If the push fails with an authentication error, your GitHub connection may need to be reactivated. Go to replit.com/integrations and reconnect your GitHub account. For organizations, make sure the Replit GitHub app is installed and authorized for your organization. If push still fails, you can use a Personal Access Token stored in Secrets as a fallback.
1# Push via Shell2git push origin main34# If authentication fails, try using a PAT5git push https://$GITHUB_TOKEN@github.com/user/repo.git mainExpected result: Your resolved merge is pushed to GitHub and visible in the repository's commit history.
Prevent future conflicts with good practices
Prevent future conflicts with good practices
While conflicts are unavoidable in collaborative work, you can reduce their frequency. Pull from GitHub before starting new work to get the latest changes. Make small, focused commits rather than large batch changes. Communicate with collaborators about which files you are working on. Use separate feature branches and merge frequently to keep divergence small. In Replit's Multiplayer mode, let Agent handle merges from the shared Kanban board when possible — it resolves most conflicts automatically.
1# Always pull before starting work2git pull origin main34# Create a feature branch for isolated work5git checkout -b feature/new-login67# Make small commits8git add src/components/LoginForm.tsx9git commit -m "Add login form component"1011# Merge frequently to stay close to main12git merge mainExpected result: Your team experiences fewer conflicts because changes are small, branches are short-lived, and everyone starts from the latest code.
Complete working example
1#!/bin/bash2# Merge conflict resolution workflow for Replit Shell3# Run each command sequentially in Shell45# Step 1: Pull latest changes (may create conflicts)6git pull origin main78# Step 2: Check which files have conflicts9echo "--- Conflicted files ---"10git diff --name-only --diff-filter=U1112# Step 3: Open and resolve each file in the editor13# (Remove <<<<<<< HEAD, =======, and >>>>>>> markers)14# Keep the code you want1516# Step 4: After resolving each file, stage it17# git add <filename>18# Example:19# git add src/App.tsx20# git add src/utils/helpers.ts2122# Step 5: Verify no unresolved conflicts remain23echo "--- Remaining conflicts ---"24git diff --name-only --diff-filter=U2526# Step 6: Complete the merge27git commit -m "Resolved merge conflicts with origin/main"2829# Step 7: Push to GitHub30git push origin main3132echo "--- Merge conflict resolution complete ---"33git log --oneline -5Common mistakes when fixing Git merge conflicts in Replit
Why it's a problem: Leaving conflict markers (<<<<<<< HEAD, =======, >>>>>>>) in the code after resolving, which causes syntax errors
How to avoid: Search the file for <<<<<<< to find any remaining markers. All three marker lines must be removed for each conflict.
Why it's a problem: Running git commit before resolving all conflicts, which creates a broken commit
How to avoid: Run git diff --name-only --diff-filter=U before committing to verify all files are resolved. Git will not let you commit if unresolved conflicts exist.
Why it's a problem: Using git merge --abort when you have already resolved some conflicts, losing that work
How to avoid: Only use git merge --abort if you want to start the entire merge process over. If you have already resolved some files, continue resolving the rest instead.
Why it's a problem: Not testing the application after resolving conflicts, missing logic errors from combining two sets of changes
How to avoid: After committing the merge, press Run and test all affected features. Conflict resolution can introduce subtle bugs when both sides changed related logic.
Best practices
- Always pull from GitHub before starting new work to minimize the chance of conflicts
- Make small, focused commits so conflicts involve fewer lines and are easier to resolve
- Use feature branches for isolated work and merge them back to main frequently
- Read both sides of a conflict carefully before deciding which code to keep — sometimes you need parts of both
- Use git diff --name-only --diff-filter=U to track which files still need resolution during large merges
- Test your app after resolving conflicts to make sure the combined code actually works
- Use Agent checkpoints as a safety net — you can roll back to any previous state if a merge goes wrong
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I have a merge conflict in my Replit project after pulling from GitHub. The conflicted file is src/App.tsx with conflict markers. Explain what each section of the conflict markers means and help me decide which changes to keep based on the code I describe.
I just pulled from GitHub and have merge conflicts in multiple files. Help me resolve them. For each conflicted file, show me what both versions do and suggest which version to keep. After resolving, commit the merge with a descriptive message.
Frequently asked questions
In Multiplayer mode, Agent handles merge conflicts automatically when changes are applied from the shared Kanban board. For standard Git merge conflicts from pulling or merging branches, you need to resolve them manually in the editor or Shell.
This error usually occurs when the Git repository state is corrupted. Try closing and reopening the Git pane. If the error persists, use Shell to run git status and resolve issues from the command line. As a last resort, download your project as a ZIP and re-import it.
Go to replit.com/integrations and reactivate your GitHub connection. If that does not work, create a Personal Access Token on GitHub, store it in Replit Secrets as GITHUB_TOKEN, and push using git push https://$GITHUB_TOKEN@github.com/user/repo.git main.
Yes. Git rebase is available in Shell. Run git pull --rebase origin main to rebase your local changes on top of the latest remote changes. This creates a cleaner history but rewrites commits, which can cause issues if others have already pulled your branch.
If you have not committed yet, run git checkout -- filename to restore the conflicted version and start over. If you have committed, use git revert HEAD to undo the merge commit. Agent checkpoints also let you roll back to a previous state.
Yes. RapidDev can configure branching strategies, GitHub Actions for CI/CD, merge policies, and automated conflict detection for teams building collaboratively on Replit.
Yes. Create a .gitignore file in your project root to exclude files from version control. Common entries include node_modules, dist, .env, and .replit. Agent typically creates a .gitignore automatically when scaffolding new projects.
Run git fetch origin main to download remote changes without merging, then git diff HEAD origin/main to see all differences. This helps you anticipate conflicts before the merge begins.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation