简体   繁体   English

将更改从一个分支移动到另一个分支

[英]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. 我有master分支,从中又有A和B分支。在A分支中,已经有master的更改。 Branch B has not been created yet. 分支B尚未创建。

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. 我只是对分支A中的分支B进行了所需的更改。这些更改仅在我的计算机上,我尚未在计算机上提交它们,也未将它们同步到Git上的A分支。 (I do all this in VisualStudio). (我在VisualStudio中完成了所有这些工作)。

Is there some way to push/move the changes on my computer to a new branch B? 有什么方法可以将计算机上的更改推送/移动到新的分支B? Every file I edited is identical in master & A. 我编辑的每个文件在master&A中都是相同的。

Check out git help stash . 查看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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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