Reputation: 31
I hava a file A and 2 stash both modified file A, then I ran the command 'git stash pop' twice.
The result is first stash popped successfully,but second stash occur an error like below:
error: Your local changes to the following files would be overwritten by merge: A
Please, commit your changes or stash them before you can merge. Aborting
I need both the 2 stash, and I dont want a commit after first stash pop. So how can I fix this problem?Is There a way for me to merge this 2 stash and then just pop once to meet my request?
Upvotes: 1
Views: 739
Reputation: 247
An indication of this happening is because one cannot merge when there are local modifications. Git tries to protect you from losing those changes..
I've read that one of the solutions is to (1) commit the local changes or (2) stash them temporary or (3) discard them.
Perhaps take a look at this link for further information: Resolving Git merge conflicts.
Upvotes: 0
Reputation: 3356
You can not do that without committing your changes.
pop first stash.
git stash pop
add and Commit
git commit -m 'temp commit'
pop second stash
git stash pop
add and amend last commit
git commit --amend --no-edit
undo last commit and bring last commit changes to unstaged area
git reset HEAD~1
Upvotes: 3
Reputation: 1
You first need to handle changes on file A from first pop. Commit them and do second pop.You can then amend changes to previous commit or do a new one.
Upvotes: 0