I stashed my changes. Now I want to unstash only some files from the stash. How can I do this?
相关问题
- Why does recursive submodule update from github fa
- Extended message for commit via Visual Studio Code
- Emacs shell: save commit message
- Can I organize Git submodules in a flat hierarchy?
- Upload file > 25 MB on Github
相关文章
- 请教Git如何克隆本地库?
- GitHub:Enterprise post-receive hook
- Git Clone Fails: Server Certificate Verification F
- SSIS solution on GIT?
- Is there a version control system abstraction for
- ssh: Could not resolve hostname git: Name or servi
- Cannot commit changes with gitextensions
- git: retry if http request failed
If you
git stash pop
(with no conflicts) it will remove the stash after it is applied. But if yougit stash apply
it will apply the patch without removing it from the stash list. Then you can revert the unwanted changes withgit checkout -- files...
One more way:
Eg. To restore only ./test.c file and ./include folder from last stashed,
For Windows users: curly braces have special meaning in PowerShell. You can either surround with single quotes or escape with backtick. For example:
git checkout 'stash@{0}' YourFile
Without it, you may receive an error:
Unknown switch 'e'
I think VonC's answer is probably what you want, but here's a way to do a selective "git apply":
First list all the stashes
↓
Then show which files are in the stash (lets pick stash 1):
↓
Then apply the file you like to:
or whole folder:
It also works without
--
but it is recommended to use them. See this post.