Nikola Knezevic
Nikola Knezevic

Reputation: 799

Keep stash after git filter-branch --subdirectory-filter

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?

Upvotes: 8

Views: 641

Answers (2)

Tones29
Tones29

Reputation: 129

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

Upvotes: 3

Karl Bielefeldt
Karl Bielefeldt

Reputation: 49048

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.

Upvotes: 0

Related Questions