Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git stash in Qt Creator fails if new files have been added to the project since last commit

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
like image 526
sashoalm Avatar asked Jan 08 '13 10:01

sashoalm


1 Answers

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

like image 59
uday Avatar answered Sep 23 '22 00:09

uday