Inside of Git Tower I have a stash of about 26 files. However, when I try to apply the stash back onto my working tree, I get an error about trailing whitespaces.
How can I apply the stash sucessfully, getting around that error?
Here's the full error message:
<stdin>:87: trailing whitespace.
// query code
<stdin>:88: trailing whitespace.
// query code
<stdin>:104: trailing whitespace.
// query code
<stdin>:118: trailing whitespace.
// query code
<stdin>:119: trailing whitespace.
//error code
error: patch failed: app/Http/Controllers/ProjectController.php:43
error: app/Http/Controllers/ProjectController.php: patch does not apply
error: patch failed: resources/views/projects/filter.blade.php:1
error: resources/views/projects/filter.blade.php: patch does not apply
Conflicts in index. Try without --index.
Conflicts in index. Try without --index.
This means that you tried git stash apply --index
and there were conflicts while Git tried to apply the stashed patch. When Git encounters conflicts, the conflicting state is stored in the index, to prevent you from accidentally committing unresolved conflicts and to remind you to actually solve those conflicts first. Thus, explicitly restoring the stashed index state will fail when Git would need the index for those conflicts.
This is also explained in the documentation:
If the
--index
option is used, then tries to reinstate not only the working tree’s changes, but also the index’s ones. However, this can fail, when you have conflicts (which are stored in the index, where you therefore can no longer apply the changes as they were originally).
So the solution, as the error message suggests, is to use the command without --index
.
If Git Tower automatically does that for you, then you might have to restore the stash from the command line here.