1

I have two branches feature/A and feature/B. I have modified the files of feature/A and apply git stash command to save my work and git checkout feature/B to switch to other branch. Now on feature/B I have modified files and applies git stash to save the work at feature/B.

Now if I want to again reflect my changes I have to apply git stash pop but my question is the saved work of both the branches reflect at once when I apply git stash pop or the work is saved as per the branches (i.e. In feature/A the work of particular branch only reflects and in feature/B the work of particular branch is reflect)?

Harry
  • 154
  • 4
  • 15

1 Answers1

0

You may pop or apply the relevant stash by index upon returning to the feature/A branch. Consider this workflow:

# work on feature/A
git stash

# work on feature/B
git checkout feature/B
git stash

# now return to feature/A and apply the first stash
git checkout feature/A
git stash apply "stash@{0}"

# switch to feature/B and apply the correct stash there
git checkout feature/B
git stash apply "stash@{1}"
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360