I have an issue in git stash.
Say for example I have 3 files say a.txt,b.txt & c.txt in the repo and the directory is clean.
Now I'm modifying 2 files among them : a.txt and b.txt.
Now I havent completed my changes in thw two files so I am stashing them by the foll command:
$ git stash save "First Stash" No if I do a $ git stash list, I get
stash@{0}: On master: First Stash No if I modify the third text file c.txt and stash that as well as shown:
$ git stash save "Second Stash" No finally if I do a $git stash list I'm getting the foll result,
stash@{0}: On master: Second stash stash@{1}: On master: First Stash The stash number and the messages are mixed up here.What's going on here? Now if i pop the stash@{0} I get the first stash contents but the message reversed here which is displaying as Second stash but should have been First Stash.
This is my work flow
admin:stud:/demo/stash_demo> ls a.txt b.txt admin:stud:/demo/stash_demo> echo Hello World >> a.txt admin:stud:/demo/stash_demo> git stash save "First" Saved working directory and index state On master: First HEAD is now at cff03c6 Initail Commit admin:stud:/demo/stash_demo> echo Hello World >> b.txt admin:stud:/demo/stash_demo> git stash save "Second" Saved working directory and index state On master: Second HEAD is now at cff03c6 Initail Commit These are my available stashes:
admin:stud:/demo/stash_demo> git stash list stash@{0}: On master: Second stash@{1}: On master: First Now I''ll be trying to apply the stash@{1} which is the first stash and should apply the file a.txt
admin:stud:/demo/stash_demo> git stash apply `stash@{1}` # On branch master # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: b.txt # no changes added to commit (use "git add" and/or "git commit -a") As seen above I get the most recent changes applied.
And if i try without the ticks `` then it gives me the foll error.
admin:stud:/demo/stash_demo> git stash apply stash@{1} fatal: ambiguous argument 'stash@1': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]'
git stash applyignoring unknown stash names silently and just applyingstash@{0}instead.stash@1: Command not foundand the most recent stash is applied.I think the syntax which I'm using is wrong.But if I try without he backticks nothing happens.