git 将未提交的更改移动到新分支

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13687334/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 15:01:27  来源:igfitidea点击:

Moving uncommitted changes to a new branch

git

提问by James Raitsev

Possible Duplicate:
Move existing, uncommited work to a new branch in Git

可能的重复:
将现有的、未提交的工作移动到 Git 中的新分支

I have some code in branch ABC.

我在分支 ABC 中有一些代码。

After making some changes to it, i'd like to move all those uncommitted changes into a commit on a new branch ABC_1.

对其进行一些更改后,我想将所有未提交的更改移动到新分支 ABC_1 上的提交中。

How can this be done please?

请问这怎么办?

回答by Abizern

Just create a new branch:

只需创建一个新分支:

git checkout -b newBranch

And if you do git statusyou'll see that the state of the code hasn't changed and you can commit it to the new branch.

如果你这样做了,git status你会看到代码的状态没有改变,你可以将它提交到新分支。

回答by rohit89

Just move to the new branch. The uncommited changes get carried over.

只需移动到新的分支。未提交的更改会继续执行。

git checkout -b ABC_1

git checkout -b ABC_1

git commit -m <message>

git commit -m <message>

回答by CharlesB

Just create a new branch with git checkout -b ABC_1; your uncommitted changes will be kept, and you then commit them to that branch.

只需创建一个新分支git checkout -b ABC_1;您未提交的更改将被保留,然后您将它们提交到该分支。