Max Koretskyi
Max Koretskyi

Reputation: 105439

git stash apply results in the conflict - why?

I've just tried to unstash changes and git reported a conflict:

Auto-merging core/scaldi/modules.scala
CONFLICT (content): Merge conflict in core/scaldi/modules.scala

I'm curious as to why this conflict occurs, since I have no changes neither in working directory nor in the index:

git diff          #outputs nothing
git diff --cached #outputs nothing
git status        #outputs `nothing to commit, working directory clean`

Upvotes: 0

Views: 948

Answers (2)

Tung Fam
Tung Fam

Reputation: 8147

Solution that worked for me.

Imagine you were working in branch feature/abc

  1. Switch to develop branch. Fetch and Pull from develop branch.
  2. Go back to feature/abc branch. Rebase feature/abc changes onto develop.
  3. Apply stash again. It should work now.

Upvotes: 0

phts
phts

Reputation: 3915

'm curious as to why this conflict occurs, since I have no changes neither in working directory nor in the index:

It's not enough. Seems you stashed changes some commits ago.

Assume your tree looks like this:

A------B------C------D[master]
        \                
         stashed -------^ (stash apply)
         sources

So stashed file changes of core/scaldi/modules.scala conflicts with some changes in C or D.

Upvotes: 3

Related Questions