Search code examples
gitwebstorm

Can't stash changes with Git


I have changed some files and I want to stash these changes but when I run;

git stash save "teststash"

from command line, It gives error;

Cannot save the current index state

I am using Webstorm and also I cannot stash any changes with it also. WebStorm gives same error;

tried to save uncommitted changes in stash before merge, but failed with an error. 
Couldn't stash file://C:/Projects/myproject: Cannot save the current index state

EDIT:

git -status

Here is the output of status command;

On branch branch111
Your branch is up to date with 'origin/branch666'.

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:   package-lock.json

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    sh.exe.stackdump

no changes added to commit (use "git add" and/or "git commit -a")

Solution

  • git stash save is deprecated as of 2.15.x/2.16.

    You may use git stash push -m "message" where "message" is your note for that stash.

    If you wish to retrieve the stash, first list all the the stashed items and choose the suitable one.

    use git stash list to list out all the stashed items. And to apply any stashed item git stash apply stash@{<stash_id>}

    Git Stash Document: Git Stash Man Page