Git:我可以提交我的工作目录到一个新的分支而不需要提交给当前分支吗? [英] Git: Can I commit my working directory to a new branch without committing it to a current branch?

查看:143
本文介绍了Git:我可以提交我的工作目录到一个新的分支而不需要提交给当前分支吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个项目,并将所有测试都传递给了master分支。然后我做了一些改变,当一切开始失败时,我意识到也许我应该在不同的分支上做出这些改变。有没有一种方法可以将更改提交到一个新的分支,而无需将它们提交给我的主分支,这样主人仍然具有我的通过测试? / b> $ p
$ b

  $ git checkout -b new-branch 

是的,只需创建新分支并检出它:

然后提交您所有的更改。他们将被应用到新的检出分支。


I am working on a project, and had all of my tests passing on the master branch. I then made some changes, and when everything started failing, I realized that maybe I should have made those changes on a different branch. Is there a way I can commit the changes to a new branch without committing them to my master branch, so that the master still has my passing tests?

解决方案

Yes, just create the new branch and check it out:

$ git checkout -b new-branch

Then commit any changes you have. They'll be applied to the new, checked-out branch.

这篇关于Git:我可以提交我的工作目录到一个新的分支而不需要提交给当前分支吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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