git
stash
conflict resolution
git commands
version control

How to resolve git stash conflict without commit?

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

git stash is useful because it lets you shelve local changes without making a commit, but conflicts can appear when you reapply the stash onto a changed working tree. The good news is that you do not need to create a commit just to finish resolving the conflict and keep working.

What a Stash Conflict Actually Means

A stash is basically a recorded patch plus metadata about the state of your worktree. When you run git stash apply or git stash pop, Git tries to merge those saved changes back into your current files.

If the same lines were edited in both places, Git cannot decide which version should win. That is the same core problem as a merge conflict, except the source of one side is the stashed change instead of another branch.

The Normal Resolution Flow

Start by checking the current status:

bash
git status

You will see conflicted files listed as unmerged. Open those files and look for conflict markers such as:

text
1<<<<<<< Updated upstream
2current branch content
3=======
4stashed content
5>>>>>>> Stashed changes

Edit the file so it contains the final content you actually want, then remove the conflict markers.

After each file is fixed, stage it:

bash
git add path/to/file

That marks the conflict as resolved. Staging is enough. You do not have to commit unless you actually want a commit for your workflow.

apply Versus pop

The difference matters during cleanup:

  • 'git stash apply reapplies the stash but keeps the stash entry'
  • 'git stash pop reapplies the stash and tries to drop the stash entry afterward'

When pop hits conflicts, Git usually keeps the stash entry because the apply step did not finish cleanly. That is helpful, because you can retry or inspect it again if needed.

A careful workflow is:

bash
git stash list
git stash apply stash@{0}

Resolve the conflicts, stage the files, and only drop the stash when you are satisfied:

bash
git stash drop stash@{0}

This is safer than using pop when you already expect a messy reapply.

Keeping the Resolution Without Committing

Once all conflicted files are edited and staged, your stash conflict is resolved from Git's point of view. At that stage you can:

  • keep working and make more edits
  • unstage files if you want them back in the regular working tree
  • commit later when it makes sense

For example:

bash
1git status
2git add src/app.py
3git add README.md
4git status

If you want the files resolved but not staged, unstage them after the conflict is cleared:

bash
git restore --staged src/app.py README.md

That leaves the resolved content in your working tree without creating a commit.

Useful Conflict Helpers

If you want to accept one side wholesale for a file, Git provides shortcuts. On many Git versions, these are easier to reason about than manual editing for simple cases:

bash
git checkout --ours path/to/file
git checkout --theirs path/to/file

Then stage the chosen file:

bash
git add path/to/file

You should still inspect the result carefully. In a stash conflict, "ours" and "theirs" refer to merge sides, not necessarily the labels you would intuitively guess from the stash command alone.

If You Want to Abort Instead

Sometimes the best answer is to back out and try again on a cleaner branch. If you used git stash apply and have not gone far, you can discard the conflicted worktree changes and start over on a safer base.

A lower-risk operational habit is:

  1. use git stash apply instead of pop
  2. inspect conflicts
  3. resolve or abandon
  4. drop the stash only after success

That pattern gives you a recovery path without forcing a commit.

Common Pitfalls

  • Thinking git add means you are forced to commit immediately, when it only marks the conflict as resolved.
  • Using git stash pop by default even when apply would give you a safer retry path.
  • Forgetting to remove conflict markers before staging the file.
  • Dropping the stash entry before you verify that the resolved working tree is actually correct.
  • Choosing --ours or --theirs without inspecting which side contains the content you want.

Summary

  • A stash conflict is resolved like any other Git merge conflict: edit, then stage the file
  • You do not need to make a commit just to finish the stash resolution
  • 'git add marks a file as resolved; it does not force an immediate commit'
  • 'git stash apply is often safer than git stash pop when conflicts are possible'
  • After resolving, you can keep working, unstage files, and commit later on your own schedule

Course illustration
Course illustration

All Rights Reserved.