I tried saving a git state using : git stash save changes_1. I can see the stash list using: git stash list
But when I try to apply the stash using: git stash apply stash@{0}. Now, I cannot see any changes are getting updated with git diff. a开发者_如何学Cnd it is showing the message "Already uptodate!"
So, in short git stash is not able to apply the changes saved. Any help.
This happens when a stash was applied previously or applying it does nothing e.g. current branch already has those changes. Consider the following scenario:
$ git diff
diff --git a/test.txt b/test.txt
index e69de29..9daeafb 100644
--- a/test.txt
+++ b/test.txt
@@ -0,0 +1 @@
+test
$ git stash
Saved working directory and index state WIP on master: b1d46d2 test.txt
HEAD is now at b1d46d2 test.txt
Now we re-add that line by hand and commit it:
$ git diff
diff --git a/test.txt b/test.txt
index e69de29..9daeafb 100644
--- a/test.txt
+++ b/test.txt
@@ -0,0 +1 @@
+test
$ git commit -a
[master 8efb415] test.txt
1 files changed, 1 insertions(+), 0 deletions(-)
$ git stash list
stash@{0}: WIP on master: b1d46d2 test.txt
$ git stash apply stash@{0}
# On branch master
nothing to commit (working directory clean)
Here git stash apply
does nothing.
Try git status -s to see if the changes are there.
If they are there you are all set, if not use git stash list and make sure your saved stash is at index 0. If you try to apply a stash that has changes that are already part of the working branch it will be already up to date.
If you wanted you could reset your current branch to the last commit. Git reset --hard HEAD and then try to apply that stash again. Care as all current changes not stashed and commits not pushed will be lost.
精彩评论