Pergunta

In my current branch I have several stashes:

  • stash@{0}
  • stash@{1}
  • stash@{2}
  1. If I apply stash@{0}:

    $ git stash apply stash{0}
    
  2. Modify this stash

  3. I want to save the changes to the current stash stash@{0}

I don't want to create a 4th stash I just want to update the first stash.

Can someone tell how to do this? I'm looking at the man page… perhaps I'm overlooking something.

Foi útil?

Solução

You can stash your working tree and then drop the old one that you don't need.

git stash apply
# Make changes
git stash
git stash drop stash@{1}

Alternatively, you can pop instead of apply, which will drop the stash at the same time:

git stash pop 
# make changes
git stash

Another alternative, if you already were already making the changes that you want to do before realizing that you want to merge the changes to the top of the stash:

# make changes
git add <all files>
git stash pop # or apply
git rm --cached <files that you want to merge>
git stash --keep-index
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top