将当前更改放在新的Git分支中[重复]

时间:2022-03-24 11:13:15

This question already has an answer here:

这个问题在这里已有答案:

I've been editing some modules on the master branch but I haven't committed them. I'm now thinking that these changes should really be on an experimental branch and not the master branch.

我一直在主分支上编辑一些模块,但我还没有提交它们。我现在认为这些变化应该是实验性的分支,而不是主分支。

How can I get these edits into an experimental branch? Copy them to some temp location, create the branch, and then copy them back in?

如何将这些编辑内容转换为实验分支?将它们复制到某个临时位置,创建分支,然后将它们复制回来?

And how do I configure things so that when I do a git push from the new experimental branch it will it go into a branch of the same name in my GitHub repo?

我如何配置东西,以便当我从新的实验分支进行git推送时,它会进入我的GitHub仓库中的同名分支?

1 个解决方案

#1


301  

You can simply check out a new branch, and then commit:

您只需签出一个新分支,然后提交:

git checkout -b my_new_branch
git commit

Checking out the new branch will not discard your changes.

签出新分支不会丢弃您的更改。

#1


301  

You can simply check out a new branch, and then commit:

您只需签出一个新分支,然后提交:

git checkout -b my_new_branch
git commit

Checking out the new branch will not discard your changes.

签出新分支不会丢弃您的更改。