$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/lab_master
remotes/origin/master
$ git checkout lab_master
error: Your local changes to the following files would be overwritten by checkou t:
**project.properties**
Please, commit your changes or stash them before you can switch branches.
Aborting
为什么我无法 checkout lab_master 分支?
另一个问题:为什么我不能将当前文件与另一个分支中的文件进行比较?
$ git diff project.properties -b lab_master
fatal: bad flag '-b' used after filename
最佳答案
Git 防止您切换到另一个分支,因为这会覆盖您对文件 project.properties
应用的一些更改。您可以使用 git checkout -f lab_master
丢弃更改,或者先通过 git stash
(和 git stash pop
在检查后存储它们离开另一个分支。)如果您确定要保留更改,您也可以简单地提交它们。
关于git - 为什么我不能 checkout 另一个 git 分支?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12596767/