相关疑难解决方法(0)

更改为主分支时出错:我的本地更改将被结帐覆盖

这个问题类似于这一个,但更具体.

我有一个有两个分支(stagingbeta)的项目.

我开发staging,并使用master分支来修复错误.因此,如果我正在进行暂存并且看到错误,我将更改为master分支:

git checkout master
Run Code Online (Sandbox Code Playgroud)

做的事情:

git add fileToAdd
git commit -m "bug fixed"
Run Code Online (Sandbox Code Playgroud)

然后我合并两个分支:

git checkout staging
git merge master
git checkout beta
git merge beta
Run Code Online (Sandbox Code Playgroud)

如果工作树上有其他文件也没关系.

但是现在,当我尝试更改master分支时,我收到一个错误:

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
Run Code Online (Sandbox Code Playgroud)

我以为我应该从暂存区域中删除该文件:

git reset HEAD src/Pro/ConvocationBundle/Controller/DefaultController.php
Run Code Online (Sandbox Code Playgroud)

但是我得到了同样的错误.如果git …

git git-checkout

107
推荐指数
5
解决办法
15万
查看次数

为什么我不能结帐另一个git分支?

$ 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 version-control git-diff git-checkout git-branch

2
推荐指数
1
解决办法
1万
查看次数