When I've just made changes to files in my project since the last commit, git stash works fine.
However, if I've also added new files to the project since the last commit, it fails with this error:
C:\Program Files\Git\cmd\git.exe stash save QtCreator 2013-01-08T12:06:51
Cannot stash in "C:\MyProject": error: Entry 'NewFile.cpp' not uptodate. Cannot merge.
Cannot save the current worktree state
Why does it show this error, and is there a way stash my changes if I've added new files to the project?
Edit
Here is the output of git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: NewFile.cpp
#
# 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: MyFile.cpp
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# MyProject.pro.user
As Scott Chacon says,
Stashing takes the dirty state of your working directory — that is, your modified tracked files and staged changes — and saves it on a stack of unfinished changes that you can reapply at any time.
Since you added a new file then it doesn't know as it was not previously present, So try doing:
1) $ git add .
2) $ git stash
And see if you can able to stash those changes
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