Git:如何将自上次提交以来的更改移动到新分支
我一直在一个我们可以称之为“A”的分支上工作。我刚刚意识到,自上次提交以来我添加的代码应该位于特定的(实验)分支中,而不是“A”中。如何将更改提交到新分支并让分支“A”保持上次提交时的状态?
I have been working on a branch which we can call "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". How can I commit the changes to a new branch and leave branch "A" as it was when I last committed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果更改已暂存或您的工作目录,您可以简单地检出到新分支,如下所示:
然后您可以直接提交到新分支。
If the changes are staged or your working directory, you can simply checkout into a new branch like so:
You can then commit directly into the new branch.