hug*_*eow 2 git version-control git-diff git-checkout git-branch
$ 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
Run Code Online (Sandbox Code Playgroud)
为什么我只是没有结账lab_master分支?
另一个问题:为什么我无法将当前文件与另一个分支中的文件进行比较?
$ git diff project.properties -b lab_master
fatal: bad flag '-b' used after filename
Run Code Online (Sandbox Code Playgroud)
Git会保护您不要切换到另一个分支,因为这会覆盖您应用于文件的某些更改project.properties
.您可以通过使用git checkout -f lab_master
或首先通过git stash
(以及git stash pop
在签出其他分支之后)将更改丢弃.如果您确定要保留更改,您也可以简单地提交它们.