【发布时间】:2018-07-20 16:25:28
【问题描述】:
我使用 Git 2.7.4 对分支进行了一些更改。提交并推送到分支。
[user:~/terraform] mybranch ± git status
On branch DIC-98-rhel-lb0
nothing to commit, working directory clean
[user:~/terraform] mybranch ±
[user:~/terraform] mybranch ± git push origin mybranch
Everything up-to-date
当我尝试切换到大师时
[user:~/terraform] mybranch ± git checkout master
error: Your local changes to the following files would be overwritten by checkout:
azure-openshift/.gitignore
azure-openshift/bastion.tf
azure-openshift/bootstrap.sh
azure-openshift/bootstrap.tfvars
azure-openshift/cns.tf
azure-openshift/infra.tf
azure-openshift/master.tf
azure-openshift/openshift.auto.tfvars
azure-openshift/openshift.variables.tf
azure-openshift/revproxy.tf
Please, commit your changes or stash them before you can switch branches.
Aborting
[user:~/terraform] mybranch 1 ±
我也可以先做git reset,结果相同。
我错过了什么?
【问题讨论】:
-
git status的输出是什么?您使用的确切git reset命令是什么? -
@Code-Apprentice - onknows 已经在问题中包含了
git status的输出。 -
@JDB OIC...我错过了,因为我期待更多...
-
试试
git reset --hard HEAD。虽然,如果 JDB 是正确的,您的文件在 .gitignore 中,那么它可能仍然无法正常工作。 -
您的
git status输出显示On branch DIC-98-rhel-lb0(注意名称)。您的git push命令说要根据名称mybranch推送(注意不同的 名称)。
标签: git reset git-checkout