I had a bunch of staged and unstaged changes and I wanted to quickly switch to another branch and then switch back.
So I staged my changes using:
$ git stash push -a
(In hindsight I probably could have used --include-untracked
instead of --all
)
Then when I went to pop the stash I get a whole lot of errors along the lines of:
$ git stash pop
foo.txt already exists, no checkout
bar.txt already exists, no checkout
...
Could not restore untracked files from stash entry
There doesn't seem to be any changes restored from the stash.
I also tried $ git stash branch temp
but that shows the same errors.
I did figure out a way around this which was to use:
$ git stash show -p | git apply
Disaster averted for now but this raises some questions.
Why did this error happen in the first place and how do I avoid it next time?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…