Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move changes from one branch to another

Tags:

git

I just made some changes in the wrong child branch.

I have master branch and from it I have branches A and B. In branch A there are already changes from master. Branch B has not been created yet.

I just made the changes I need for branch B in branch A. These changes are on my computer only, I have not committed them yet on my computer and have not synced them to the A branch on Git. (I do all this in VisualStudio).

Is there some way to push/move the changes on my computer to a new branch B? Every file I edited is identical in master & A.

like image 971
David Thielen Avatar asked Oct 20 '25 21:10

David Thielen


1 Answers

Check out git help stash. Since you haven't made a commit with these files - your workspace is "dirty" with the changes you want to move - you can move them through the stash.

git stash # make your working directory clean, save the changes for later
git checkout master
git checkout -b B # create your new branch from master
git stash pop # apply the changes to the new branch
like image 125
Nate Bosch Avatar answered Oct 22 '25 17:10

Nate Bosch