Back to blog

How to Fix Git Error Pulling is Not Possible Because You Have Unmerged Files

When working in teams, you frequently run git pull to fetch and merge the latest remote updates. Occasionally, Git blocks your request and displays this fatal error:

fatal: Pulling is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>'
as appropriate to mark resolution and make a commit.

This error halts development. It is a protective lock: Git is refusing to start a new pull operation because your previous merge or rebase attempt encountered conflicts that were never finalized.

In this guide, we will analyze why unmerged files lock your repository, and explore three strategies to resolve the lock and pull code.

The Cause: The Unfinished Merge Transaction

When you pull code and conflicts occur, Git pauses midway and writes conflict markers (like <<<<<<< HEAD) into the affected files. These files are marked as "unmerged" in Git's index database.

At this point, Git is waiting for you to do one of two things:

  1. Manually resolve the conflicts and commit the changes to finish the merge transaction.
  2. Abort the merge to restore the repository to its pre-conflict state.

If you ignore the conflict state and attempt to run git pull again, Git blocks the request because initiating a second merge before resolving the first would corrupt your file history.

Solution 1: Resolve the Conflicts (Proceed with Merge)

To preserve your work and complete the merge, follow these steps:

Step 1: Identify the Unmerged Files

Run git status to view which files are causing the merge lock:

git status

In the output, look for files marked as "both modified" under the unmerged paths list:

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   src/app.ts

Step 2: Fix Conflict Markers in Your Editor

Open the listed files in your IDE. Locate the conflict blocks:

<<<<<<< HEAD
const apiUrl = "https://api.local";
=======
const apiUrl = "https://api.production";
>>>>>>> origin/main

Remove the markers (<<<<<<<, =======, >>>>>>>) and edit the code to keep the correct version.

Step 3: Stage and Commit the Resolution

Once you save the edited files, tell Git that the conflicts are resolved by staging the files, and then commit to finalize the merge transaction:

# Mark files as resolved
git add src/app.ts

# Finalize the merge transaction
git commit -m "Merge resolved and synced"

With the merge transaction complete, your repository state returns to clean. You can now execute git pull normally.

Solution 2: Abort the Merge (Rollback Changes)

If you made a mistake during the merge, or if pulling remote updates brought too many conflicts and you want to start over, you can abort the merge.

Run the abort command:

git merge --abort

This command rolls back your files, undoes the conflict state, and restores your working directory to the exact state it was in before you ran the failed pull. The unmerged files lock is instantly removed.

Solution 3: Force Reset (Discard Local Changes)

If you do not care about your local changes and want to force your local repository to match the remote server state exactly, execute a hard reset.

  • Warning: This action is destructive. Any uncommitted local work will be permanently deleted.
# Reset your local branch and discard all local edits
git reset --hard HEAD

Alternatively, to force-align your local branch to match the remote branch:

# Discard local changes and align history to the remote main
git reset --hard origin/main

Once executed, your index tree is clean, and you can pull updates without warnings.

Conclusion

The "Pulling is not possible" error occurs when a previous merge conflict remains unresolved. To clear this state, inspect conflicted paths using git status, resolve the code markers and run git add and git commit to finalize the merge transaction, execute git merge --abort to discard the merge attempt and restore the repository state, or perform a hard reset to match remote tracking branches.