Git allows for branch change with unstaged changes

前端 未结 2 629
有刺的猬
有刺的猬 2020-11-27 14:05

Git is allowing me to change branches when I have changes not staged for commit (modified files).

Is there a configuration for this somewhere?

Edit: At first

2条回答
  •  时光取名叫无心
    2020-11-27 14:48

    As Emily pointed out, this is a feature. Git will only disallow the branch change if performing the change would require modifying any of the files that have unstaged changes. If all of the modified files will be untouched by the branch checkout, git will not complain at all. This means that regardless of what branch you check out, you can always check out the previous branch and your working tree will be identical to how you left it.

提交回复
热议问题