tl;dr
Before git stash pop, I should do git commit -a -m "wip".
Then all I have to do to fix stash confliction is,
git resetgit checkout ./git clean -df
When I got CONFLICT error of git stashing…
Imagine I got error on git stash pop like below,
$ git stash list
stash@{0}: WIP on master: efgh5678 bar
stash@{1}: WIP on master: abcd1234 foo
$ git stash pop
Auto-merging foo.go
CONFLICT (modify/delete): bar.go deleted in Updated upstream and modified in Stashed changes. Version Stashed changes of bar.go left in tree.
If I don’t have any untracked files/changes in previous state, meaning I’ve already committed all of the changes, then I should do
# Cancel and back the staged files
$ git reset
# Cancel the changes on tracked files
$ git checkout ./
# See the all of new files
$ git clean -n
Would remove bar.go
# Remove all of new files (delete them!)
$ git clean -df
Besides above, if I don’t need the stashed changes,
$ git stash list
stash@{0}: WIP on master: efgh5678 bar
stash@{1}: WIP on master: abcd1234 foo
# see the stashed files
$ git stash show stash@{0}
bar.go | 4 ++
foo.go | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
# see the stashed changes, like `git diff`
$ git stash show -p stash@{0}
# delete the stashed changes
$ git stash drop stash@{0}