Suppose that I have stashed some changes and I want to add further changes into the same stash (such as stash@{0}
). Is there an easy way to do this? What about combining two stashes into a single one?
I don't see any "git stash
" option allowing to modify an existing git stash.
A possible way to achieve this would be:
stash@{1}
)stash@{2}
)tmp
branch from the commit (HEAD
) your are currently modifyinggit stash pop
twicegit stash
, creating a new stash@{1}
with both content in it, git stash pop
once (to restore all the pending changes)Five years later, Powerslave proposes in the comments:
The branching magic is completely unnecessary.
You could simply
- Create a new stash with whatever you have.
git stash apply
both changesets (you cangit stash pop
instead, but in that case you're in trouble if you accidentally screw up).- Create a new stash with these merged changes.
git stash drop
the other two changesets if you usedapply
instead ofpop