Git allowing me to switch branches without committing changes -


i learning git, going through tutorial. in branch seo_title , have uncommitted changes file mission.html. did git checkout master expecting warning changes not staged commit, no changes added, etc, instead went ahead , switched branches message:

m       mission.html switched branch 'master' 

then when did git diff mission.html showed me working directory still contains changes made while had other branch checked out. missing? it's worth, using git bash on windows.

edit: changes mission.html have not been added staging index either.

edit 2: thought top voted answer correct, upon further investigation doesn't match behavior seeing. here fuller description of doing:

top_directory(master) > git branch new_branch_1 top_directory(master) > git branch new_branch_2 top_directory(master) > git checkout new_branch_1 

(open notepad++ , modify resources.html, save)

top_directory(master) > git status # on branch new_branch_1 # changes not staged commit: #   (use "git add <file>..." update committed #   (use "git checkout -- <file>..." discard changes in wo # #       modified:   resources.html # no changes added commit (use "git add" and/or "git commit top_directory(new_branch_1) > git checkout new_branch_2 

this expect git object , tell me stash or commit since new_branch_1 , new_branch_2 have different versions of resources.html, switches new branch without warning , brings uncommitted changes along:

m       resources.html switched branch 'new_branch_2' top_directory(new_branch_2) > git status # on branch new_branch_2 # changes not staged commit: #   (use "git add <file>..." update committed) #   (use "git checkout -- <file>..." discard changes in working directory) # #       modified:   resources.html # no changes added commit (use "git add" and/or "git commit -a") 

is there mode or setting make behave way instead of warning? or still misunderstanding scenario?

edit 3: now. top rated answer right, see last comment on answer.

the different behaviour saw last time tried switch branches local changes , due different file changes.

so, let's have branch called 'readme' have committed changes file, let's readme.md.

now, have switched master. work on other files (not readme.md). have local changes. if try switch 'readme' branch without committing changes, let you. why? because switching 'readme' branch won't override of local changes.

if, make modification readme.md file on master branch, when try

git checkout readme  

you encounter

error: local changes following files overwritten checkout: readme.md please, commit changes or stash them before can switch branches. 

because have changes readme.md require merge.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -