在git中切换分支名称 [英] Switch branch names in git

查看:153
本文介绍了在git中切换分支名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能有不止一种方法来问这个问题,所以这里是对问题的解释。我一直在做主人并做了一些事情,然后决定暂时搁置这项工作。我支持了一些提交,然后在开始我的垃圾工作之前分支。实际上,这工作得很好,我现在有一个不同的分支作为我的主要开发分支。我想知道我怎么能改变事情,所以我再次在master上工作,但它没有我的垃圾工作,并表示工作是在不同的分支。



这可能会被问到/解决的一些方法:
如何将我的主分支重命名为其他名称,然后重命名其他名称以便掌握?
我如何备份master,然后导致我所备份的所有提交都在不同的分支上?



感谢所有(快速)解答!它们都很好。除了其他的评论,你可能会发现-m(move)切换到git - 分支有帮助。你可以将你的老主人重新命名为其他东西,然后将你的新分支重新命名为master:

  git branch -m master crap_work 
git branch -m previous_master master


There may be more than one way to ask this question, so here's a desciption of the problem. I was working on master and committed some stuff and then decided I wanted to put that work on hold. I backed up a few commits and then branched from before I started my crap work. Practically this works fine, I just now have a different branch as my main development branch. I'm wondering how I could change things around so I'm working on master again but it doesn't have my junk work and said work is on a different branch.

Some ways this could be asked/solved: How do I rename my master branch to something else and then rename something else to master? How do I back up master and then cause all commits I've backed up past to be on a different branch?

Thanks for all the (quick) answers! They're all good.

解决方案

In addition to the other comments, you may find the -m (move) switch to git-branch helpful. You could rename your old master to something else, then rename your new branch to master:

git branch -m master crap_work
git branch -m previous_master master

这篇关于在git中切换分支名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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