Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git not asking to commit before switching branches

Tags:

git

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.

like image 322
Uri Avatar asked Apr 19 '26 20:04

Uri


1 Answers

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
like image 61
johusman Avatar answered Apr 21 '26 10:04

johusman