Aruna Karunarathna
Aruna Karunarathna

Reputation: 1021

How to stash current changes and apply it to a new branch

I'm currently working on a project git is used as the version control. I'm currently in the 0.27.0.i1 branch. And I have some changes which have not still committed to the master branch. These changes has to be committed to the new 0.27.0.i2 branch which originated from the 0.27.0.i1.

How can I stash changes from the 0.27.0.i1 and apply the stashed changes on the 0.27.0.i2 branch.

Upvotes: 3

Views: 3788

Answers (2)

René Höhle
René Höhle

Reputation: 27325

When you haven't changes in the target branch you can simply checkout the new branch. Then all your changes will be in the new branch.

When you have changes in the new branch you can't checkout the other branch but in your case its not a problem i think.

Upvotes: 1

Petr Mensik
Petr Mensik

Reputation: 27536

Just do

git stash
git checkout 0.27.0.i2
git stash pop
git commit -a

Upvotes: 4

Related Questions