Search code examples
gitgit-stash

Use specific changes from my stash list


Is there a way to use specific changes from my stash list. For example my stash list shows 2 entries stash@{0} and stash@{1} now I would want to apply {0} to some X branch and {1} to some Y branch. How can I do that? Also can I delete a specific change from the list?


Solution

  • To apply a specific stash to a branch, first switch to the desired branch:

    git checkout branchA
    

    And then apply the desired stash with one of the following commands:

    git stash apply stash@{n}
    

    or

    git stash pop stash@{n}
    

    The apply command will leave your stash in the list so you can use it later, if you don't need to keep the stash you can use the pop command.

    Here you'll find the entire documentation about git stash commands: git-stash Documentation