git - 检查未在当前分支中转移到另一个分支的更改

时间:2014-08-13 22:55:00

标签: git

我不相信这有一个简单的解决方案,但我会尝试。

我在当前的分支中做了很多改动,从我的一个小想法开始。现在我意识到这应该进入一个单独的分支。

我现在可以创建一个新的分支并检查它的内容吗?

E.g。我希望从分支current进行以下所有更改,进入新分支experiment

# On branch current
# Changes not staged for commit:
#....
#      modified: Gemfile
#      modified: Gemfile.lock
#      modified: app/controllers/site_controller.rb
#      modified: app/views/sites/_form.html.erb
#
# Untracked files:
#...
#      app/models/user.rb
#      #some more files

1 个答案:

答案 0 :(得分:0)

如果您在工作区中签出了一个包含非分段更改的新分支,git将只是尝试将这些更改应用于新分支。

$ git branch myFeature
$ git checkout myFeature
M       Gemfile
M       Gemfile.lock
M       app/controllers/site_controller.rb
M       app/views/sites/_form.html.erb
Switched to branch 'myFeature'

如果更改未能应用于您正在检出的分支机构,则可能会出现问题,但在创建全新分支机构的情况下,情况永远不会如此。

相关问题