Tres
Tres

Reputation: 1495

How do I merge local modifications with a git stash without an extra commit?

I stashed my changes to work on another task. When I finished the other task, I resumed work on the modifications I stashed, except that I forgot to pop them first. Now I have partially completed work both as local modifications and in the git stash. When I try to merge them using git stash pop, I get the following error:

error: Your local changes to the following files would be overwritten by merge:
    file.js
Please, commit your changes or stash them before you can merge.
Aborting

I would like git to merge the stashed changes locally before committing. I've tried searching around a bit for a solution but have come up empty so far.

Your help is much appreciated!

Upvotes: 5

Views: 1441

Answers (1)

Tres
Tres

Reputation: 1495

I figured it out. I needed to stage my local changes for commit prior to git stash pop, so I just did a git add file.js and then git stash pop and the merge proceeded as expected. Hope this helps someone!

Upvotes: 15

Related Questions