Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git stash apply unknown option: -encodedCommand error

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
like image 686
Alex KeySmith Avatar asked Jun 15 '18 09:06

Alex KeySmith


People also ask

Does git stash apply to untracked files?

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.

What is apply stash in git?

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.

How do I reapply git stash?

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.

How do I apply a specific file in 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.


1 Answers

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).

like image 176
Alex KeySmith Avatar answered Sep 21 '22 18:09

Alex KeySmith