切换分支尽管修改文件 [英] switching branch despite of modified files

查看:109
本文介绍了切换分支尽管修改文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

另一个问题有人这样做:

  $ 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
切换到分支'暂存'

这怎么可能? git通常会拒绝在未提交更改的情况下更改分支。



我玩了一下,但确实无法解决这种情况。 - 有什么步骤让它产生类似上述输出的情况? 解决方案

并不是说Git拒绝允许分支以未改变的更改进行更改。它不允许更改将被覆盖更改的分支。



在您的情况下,我假设列出的文件在分支之间具有相同的提交状态。 b

如果您希望看到这种输出与当前分支重复,请对某些文件进行一些更改,然后切换到其他分支。

  git分支newBranch 
<编辑一些文件>
git checkout newBranch

现在结帐显示了这种输出。


In another question someone did this:

$ 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'

How is this possible? git usually refuses to change branch in case of uncommitted changes.

I played a bit, but did really not manage to get in such a situation. - What are the steps to get it a situation producing something like the above output?

解决方案

It's not that Git refuses to allow a branch to change with uncommitted changes. It disallows changing a branch where changes would be overwritten.

In your case I assume that the listed files have the same committed state between branches.

If you want to see this kind of output duplicate your current branch, make some changes to some files and then switch to the other branch.

git branch newBranch
<edit some files>
git checkout newBranch

The checkout now shows exactly this kind of output.

这篇关于切换分支尽管修改文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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