忘记创建新分支.如何将更改转移到新分支 [英] Forgot to create new branch. How to transfer changes to new branch

查看:264
本文介绍了忘记创建新分支.如何将更改转移到新分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这有时会发生在每个开发人员身上.您开始编码新功能,而忘记先在本地分支.

this happens to every developer time-to-time. You start coding a new feature and forget to branch first locally.

因此,如果发生这种情况,我可以说一声嘿,将这些未提交的(或已提交的-是的,我知道这是我要介绍的两种情况)转移到本地的新分支中,以便我不必撤消它们并将我的更改复制到新分支中就可以继续我的方式了吗?

So if that happens is there a way I can say hey, transfer these uncommitted (or committed - yea I know those are both two scenarios which I'd like to cover with this) to a new branch for me locally so I don't have to back them out and copy my changes to a new branch to be able to carry on my way?

推荐答案

如果尚未提交更改,则可以在提交之前切换到新分支.

If you haven't commited your changes yet, you can switch to a new branch prior to committing.

git checkout -b my-new-branch

这将创建一个名为my-new-branch的新分支,并立即将其检出.

This will create a new branch called my-new-branch and immediately check it out.

这篇关于忘记创建新分支.如何将更改转移到新分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆