Git stash pop error
When do git stash pop
, a possible error is: Your local changes to the following files would be overwritten by merge.
$ git stash pop
error: Your local changes to the following files would be overwritten by merge:
src/store.js
Please commit your changes or stash them before you merge.
Aborting
The stash entry is kept in case you need it again.
Possibly you have uncommitted work in the file store.js, or there will be conflict in the file after git stash pop.
A solution is:
git add src/store.js
git stash pop
Then modify the conflict in store.js, do git add src/store.js
, git commit -m "xxx"
, problem solved.
git stash
pop [--index] [-q|--quiet] [<stash>]
Remove a single stashed state from the stash list and apply it on top of the current working tree state, i.e., do the inverse operation of git stash push. The working directory must match the index.Applying the state can fail with conflicts; in this case, it is not removed from the stash list. You need to resolve the conflicts by hand and call git stash drop manually afterwards.
If the --index option is used, then tries to reinstate not only the working tree’s changes, but also the index’s ones. However, this can fail, when you have conflicts (which are stored in the index, where you therefore can no longer apply the changes as they were originally).
When no <stash> is given, stash@{0} is assumed, otherwise <stash> must be a reference of the form stash@{<revision>}.
apply [--index] [-q|--quiet] [<stash>]
Like pop, but do not remove the state from the stash list. Unlike pop, <stash> may be any commit that looks like a commit created by stash push or stash create.