When applying a git stash with the command:
git stash apply stash@{1}
As suggested in the documentation on git stash.
I receive the error:
unknown option: -encodedCommand error
By default, git stash will stash only modified and staged tracked files. If you specify --include-untracked or -u , Git will include untracked files in the stash being created.
The git stash command takes your uncommitted changes (both staged and unstaged), saves them away for later use, and then reverts them from your working copy. For example: $ git status On branch main Changes to be committed: new file: style.
To retrieve changes out of the stash and apply them to the current branch you're on, you have two options: git stash apply STASH-NAME applies the changes and leaves a copy in the stash. git stash pop STASH-NAME applies the changes and removes the files from the stash.
Apply Git stashes Now that you have saved your Git stashes on the side, you might want to “take them out from the stack” and apply them to your current working directory. In order to apply your Git stash to your current working directory, use the “git stash apply” command and specify the stash you want to apply.
What I didn't realise...
I was in powershell (to use posh-git) and of course {} is indicating powershell code.
Therefore surrounding in '' will ensure powershell interprets it as a string.
git stash apply 'stash@{1}'
Notably posh-git autocompletes the name when pressing tab (which made me realise my error).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With