fly.bird
fly.bird

Reputation: 131

git stash gives merge error / conflict that is unable to resolve

I already have stashed my changes and I can see them when I use git stash list. I did git pull --rebase upstream master successfully. (It had conflict in FileA, I resolved it.) Now I want to get my latest stashed changes at stash@{0}:. So I use git stash apply 0. Its gives me message Merge conflict in .gitignore. I fixed / merged/ resolved conflict in .gitignore.

Then did git stash apply 0, I received same error Merge conflict in .gitignore. This time I again fixed .gitignore, and I committed this .gitignore file hoping it would take care. ( I did look up on stakcoverflow and found exact same issue faced by someone and took steps).

Then I again did git stash apply 0 and same error again in loop. How to get past this error.

After git stash apply , I don't see all my changes that are supposed to be applied from the stash. I just get the conflict message for .gitignore but don't see other changes that I would like to see.

Upvotes: 0

Views: 111

Answers (1)

torek
torek

Reputation: 488193

git stash apply takes the commits that git stash made and attempts to apply (merge) them.

This attempt either succeeds, or stops with a merge conflict:

  • If it succeeds, Git has done its best to apply the stash. View the result (however you like) and if you like it, use git stash drop to discard the stash commits.

  • If it fails, Git has still done its best to apply the stash. View the result, resolve conflicts, and if you like the end result, use git stash drop to discard the stash commits.

In other words, don't keep re-applying the difference between the stashed commits and your current, in-progress work.

Upvotes: 1

Related Questions