8

I recently split out my repository (residing in bigproj) using git filter-branch --subdirectory-filter deep/in/my/project. Then, I moved .git directory to deep/in/my/project.

Now, stash is in a strange state, where the top stash is something like:

stash@{0}: filter-branch: rewrite

I can't drop this stash, as I get this error (after git stash drop):

refs/stash@{0}: not a valid stashed state

Now, even if I know the refid of stash@{1}, it still contains diffs for files in bigproj hierarchy. Is it possible to re-write stash data, so that it only contains files belonging to deep/in/my/project hierarchy?

2 Answers 2

3

I had the same problem after using git filter-branch. The following command prunes the stash completely and therefore also deletes the entries created by git filter-branch. Warning! that all stashed changes may be impossible to recover after calling this command, so make sure to apply all other stashed states before you call the command.

    git stash clear
1
  • But I don't want to kill the whole stash, I want to keep it, just without parts that are not in the repo anymore. Dec 18, 2013 at 8:34
0

I'm guessing you have to do the drop and pop before you move the .git directory. You can always re-stash it after you move.

2
  • Nope, that doesn't work. Even if I try git stash drop before moving the .git dir, I get the same error. What do you mean by re-stash? Aug 12, 2011 at 13:25
  • 1
    Hmm, apparently stash doesn't survive the filter-branch process for some reason. You're probably going to have to go back to your unfiltered state and just commit those changes instead, then after the filter do a git reset HEAD~1 to make them uncommitted again. Aug 12, 2011 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.