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?
In its simplest form, the git stash command creates a stash entry. To reapply our stashed changes at a later point, we can use git stash apply . We can apply the stash entry to a different branch – it doesn't have to be the branch that we created the stash from.
git-filter-branch can be used to get rid of a subset of files, usually with some combination of --index-filter and --subdirectory-filter .
Git stash saves the uncommitted changes locally, allowing you to make changes, switch branches, and perform other Git operations. You can then reapply the stashed changes when you need them. A stash is locally scoped and is not pushed to the remote by git push .
To stash a specific file, use the “git stash push” command and specify the file you want to stash. However, the other tracked files that may be modified in your current working directory are untouched.
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
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