Search code examples
gitversion-controlgit-stash

how to apply same stash to different branches in git?


I have four branches lets say A B C D.

I worked on branch B for some function and created stash.

This feature I also want in branch A and D .

Is there any way that I can use this stash from B and apply to A and D also and definitely I want it on B too that's why I don't want to commit instantly and go for stash.


Solution

  • git checkout A
    git stash apply
    git checkout D
    git stash apply
    

    Git won't delete your stash until you call git stash drop, so feel free to apply it to as many branches as you like!