简体   繁体   中英

Move changes from one branch to another

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM