-1

I have a stash (WIP on master a6c392c) that I would like to merger into another branch called Develop1. Develop1 is several commits behind if it matters. I do not want these changes on the master branch.

Bill Greer
  • 3,046
  • 9
  • 49
  • 80
  • 1
    Should be as easy as stashing your changes, moving to the branch, and unstashing your changes. – Kevin DiTraglia Apr 28 '16 at 12:33
  • 1
    Possible duplicate of [How to merge my local uncommitted changes into another Git branch?](http://stackoverflow.com/questions/556923/how-to-merge-my-local-uncommitted-changes-into-another-git-branch) – jonrsharpe Apr 28 '16 at 12:34
  • Note that most (all?) answers to questions about applying the stashed changes to a state of the repository different from that the stash was recorded at actually tell about *applying* the stash entry, not *merging* it -- presupposing that's what the questioneer actually *meant.* If, instead, you did really mean merging then `git stash` supports the `branch` subcommand which allows to create a proper local branch out of a stash entry; this branch can then be freely merged with `git merge`. – kostix Apr 28 '16 at 16:53

3 Answers3

1

Switch to the branch you want, then apply the stash:

$ git checkout -b Develop1

$ git stash pop
Omri Aharon
  • 16,959
  • 5
  • 40
  • 58
0

For a clean working tree:

git checkout Develop1
git stash pop
git add -A
git commit
git checkout master

For a working tree with uncommitted changes:

git stash -u
git checkout Develop1
git stash pop stash@{1}
git add -A
git commit
git checkout master
git stash pop
Melebius
  • 6,183
  • 4
  • 39
  • 52
0

Can you not just change to that branch and then do git stash pop? You might have some conflicts to resolve, which is kind of awkward with stashes.

Personally, I typically avoid using stashs and make temporary commits that I can rebase or cherry pick, and remove or squash when I'm done with them.

SpoonMeiser
  • 19,918
  • 8
  • 50
  • 68