Git 尽管修改了文件,切换分支

Git 尽管修改了文件,切换分支,git,Git,有人这样做: $ git checkout staging M app/views/comments/index.html.erb M app/views/devise/registrations/new.html.erb M app/views/devise/sessions/new.html.erb M app/views/layouts/application.html.erb M app/views/songs/contact.html.erb M app/vie

有人这样做:

$ git checkout staging
M   app/views/comments/index.html.erb
M   app/views/devise/registrations/new.html.erb
M   app/views/devise/sessions/new.html.erb
M   app/views/layouts/application.html.erb
M   app/views/songs/contact.html.erb
M   app/views/songs/faq.html.erb
M   app/views/songs/index.html.erb
M   app/views/songs/new.html.erb
M   app/views/songs/new_songs.html.erb
Switched to branch 'staging'
这怎么可能?git通常拒绝在未提交更改的情况下更改分支


我打了一点,但真的没有设法在这样的情况下要使它在产生类似上述输出的情况下运行,需要采取哪些步骤?

并不是Git拒绝允许分支使用未提交的更改进行更改。它不允许更改更改将被覆盖的分支

在您的例子中,我假设列出的文件在分支之间具有相同的提交状态

如果希望看到此类输出复制当前分支,请对某些文件进行一些更改,然后切换到其他分支

git branch newBranch
<edit some files>
git checkout newBranch
git branch newBranch
吉特纽伯兰酒店

签出现在正好显示这种输出。

并不是Git拒绝允许分支使用未提交的更改进行更改。它不允许更改更改将被覆盖的分支

在您的例子中,我假设列出的文件在分支之间具有相同的提交状态

如果希望看到此类输出复制当前分支,请对某些文件进行一些更改,然后切换到其他分支

git branch newBranch
<edit some files>
git checkout newBranch
git branch newBranch
吉特纽伯兰酒店

签出现在正好显示这种输出。

我知道
git stash
,但上面显然是
git签出
。啊,对不起。我以为你想隐藏更改并在另一个分支上工作。我不知道这是怎么可能的。我知道
git隐藏
,但上面显然是
git结帐
。啊,对不起。我以为你想隐藏更改并在另一个分支上工作。我不知道怎么可能。谢谢,这正是正确的想法。A做了一个小的编辑使它更清晰。谢谢,这正是正确的想法。A做了一个小的编辑,使它更清楚。