在当前分支上进行所有更改并将其移至Git中的新分支 [英] Take all my changes on the current branch and move them to a new branch in Git

查看:90
本文介绍了在当前分支上进行所有更改并将其移至Git中的新分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始研究我认为是我的主分支上的一个小错误修复。然而,它已经失去了控制,我希望我已经创建了一个独立的分支来进行开发。

I started work on what I thought would be a minor bug fix on my master branch. However, it has spiraled out of control to the point where I wish I had created a separate branch to do the development in the first place.

所以,现在我要说的是, (b)
$ b

So right now what I'd like to do is:


  1. 创建一个名为(说)edge的新分支

  2. 将所有已更改/未跟踪的文件移到主服务器上(例如,从开始修复错误时起,主服务器没有变化)

  3. 完成我的工作,合并回主服务器

我该如何操作?

How can I do this?

推荐答案

如果您还没有提交任何内容,那么您已经处于正确的位置。

If you haven't been committing anything yet, you're already in the right position.


  1. 创建一个新的分支: git checkout -b edge

  2. 你的文件没有改变。只需 git add 需要并按照惯例提交。 / code>,使用 git checkout 切换回 master > git merge edge

  1. Create a new branch: git checkout -b edge
  2. Your files haven't changed. Just git add what needs to and commit as usual.
  3. When you're done committing on edge, switch back to master with git checkout and git merge edge.

这篇关于在当前分支上进行所有更改并将其移至Git中的新分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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