[英]Git: Howto move changes since last commit to a new branch
I have been working on a branch which we can call "A". 我一直在研究一个我们称之为“A”的分支。 I just realized that the code I have added since I last committed should rather be in a specific (experimental) branch, but not in "A".
我刚刚意识到自从我上次提交以来我添加的代码应该是在特定的(实验性)分支中,而不是在“A”中。 How can I commit the changes to a new branch and leave branch "A" as it was when I last committed?
如何将更改提交到新分支并将分支“A”保留为上次提交时的状态?
If the changes are staged or your working directory, you can simply checkout into a new branch like so: 如果更改已暂存或您的工作目录,您可以直接签入新分支,如下所示:
git checkout -b branch_name
You can then commit directly into the new branch. 然后,您可以直接提交到新分支。
git stash
git checkout branch-A
git stash pop
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.