这个问题和这个类似,但更具体。
我有一个项目有两个分支:阶段和测试。 我在分段上开发,并使用主分支来修复错误。所以如果我正在进行分期,我看到一个错误,我改变到主分支:
git checkout master
做这些事情:
git add fileToAdd
git commit -m "bug fixed"
然后合并两个分支:
git checkout staging
git merge master
git checkout beta
git merge beta
工作树中是否有其他文件并不重要。
但是现在,当我尝试更改到主分支时,我得到了一个错误:
error: Your local changes to the following files would be overwritten by checkout:
src/Pro/ConvocationBundle/Controller/DefaultController.php
Please, commit your changes or stash them before you can switch branches.
Aborting
我认为我应该从暂存区删除文件:
git reset HEAD src/Pro/ConvocationBundle/Controller/DefaultController.php
但是我得到了同样的错误。如果我做git状态,我得到No changes to commit