切换分支时出现致命的 Git 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/180064/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 16:04:51  来源:igfitidea点击:

Fatal Git error when switching branch

git

提问by

Error message:

错误信息:

fatal: git checkout: updating paths is incompatible with switching branches/forcing

致命:git checkout:更新路径与切换分支/强制不兼容

How to get past this Git checkout error?

如何克服这个 Git 结帐错误?

采纳答案by Aristotle Pagaltzis

By explicitly specifying “git checkout HEAD $blah” instead of just saying “git checkout $blah”, assuming you did want to check out a file.

通过明确指定“ git checkout HEAD $blah”而不是仅仅说“ git checkout $blah”,假设您确实想签出文件。

You don't say what you were trying nor what you typed, however, so no one can give you anything but a blind guess.

但是,您不会说出您尝试的内容或键入的内容,因此除了盲目猜测外,没有人可以提供任何信息。

回答by Aristotle Pagaltzis

When I encounter this message, it is because I have tried to do git checkout -f $blah, expecting to throw away local changes, as described in git checkout --help.

当我遇到这个消息时,是因为我已经尝试做git checkout -f $blah,期望丢弃本地更改,如 中所述git checkout --help

Instead, I use rm $blah && git checkout $blahto throw away local changes.

相反,我rm $blah && git checkout $blah习惯于丢弃本地更改。