Get the creation date of a stash
Try: git stash list –date=local It should print something like: stash@{Thu Mar 21 10:30:17 2013}: WIP on master: 2ffc05b Adding resource
Try: git stash list –date=local It should print something like: stash@{Thu Mar 21 10:30:17 2013}: WIP on master: 2ffc05b Adding resource
git stash push has an option –keep-index that does exactly what you need. So, run git stash push –keep-index.
git shelve doesn’t exist in Git. Only git stash: when you want to record the current state of the working directory and the index, but want to go back to a clean working directory. which saves your local modifications away and reverts the working directory to match the HEAD commit. You had a 2008 old … Read more
If you do not want to specify a message with your stashed changes, pass the filename after a double-dash. $ git stash — filename.ext If it’s an untracked/new file, you will have to stage it first. However, if you do want to specify a message, use push. git stash push -m “describe changes to filename.ext” … Read more
Simple one liner I have always used git reset –merge I can’t remember it ever failing. Note: git reset –merge will discard any staged changes
git stash apply n works as of git version 2.11 Original answer, possibly helping to debug issues with the older syntax involving shell escapes: As pointed out previously, the curly braces may require escaping or quoting depending on your OS, shell, etc. See “stash@{1} is ambiguous?” for some detailed hints of what may be going … Read more
As mentioned below, and detailed in “How would I extract a single file (or changes to a file) from a git stash?”, you can apply use git checkout or git show to restore a specific file. git checkout stash@{0} — <filename> With Git 2.23+ (August 2019), use git restore, which replaces the confusing git checkout … Read more
To save a stash with a message: git stash push -m “my_stash_name” To list stashes: git stash list All the stashes are stored in a stack. To apply and remove the nth stash: git stash pop stash@{n} To apply and remove a stash by name: git stash pop stash^{/my_stash_name} To apply the nth stash: git … Read more
Yes, It’s possible with DOUBLE STASH Stage all your files that you need to stash. Run git stash –keep-index. This command will create a stash with ALL of your changes (staged and unstaged), but will leave the staged changes in your working directory (still in state staged). Run git stash push -m “good stash” Now … Read more
Don’t follow other answers… Well, you can follow them, of course. 🙂 But I don’t think that doing a commit and then resetting the branch to remove the commit you just created and similar workarounds suggested in other answers is the clean way to solve this issue. Clean solution The following solution seems to be … Read more