Git not asking to commit before switching branches

git

Solution

Git switches branches with a dirty working directory just fine if the changed files are the same on both branches. If not, it will stop you. You can override this behavior with the `-m` flag.

See

- http://www.gitguys.com/topics/switching-branches-without-committing/

- http://www.kernel.org/pub/software/scm/git/docs/git-checkout.html

Problem

If I run git status: ``` # On branch new-media # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: .gitignore # modified: app/views/layouts/application.html.erb ``` Then I checkout the master: with `git checkout master` ``` M .gitignore M app/views/layouts/application.html.erb Switched to branch 'master' ``` Previously, git stopped me from checkout other branches, prompting me to either stash or commit the changes I've made on the current one. Now, it no longer does so.

Original source