1

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?

Community
  • 1
  • 1
michas
  • 25,361
  • 15
  • 76
  • 121

1 Answers1

6

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.

Abizern
  • 146,289
  • 39
  • 203
  • 257