IDEA中Git提交时报:The Git repository at the following path is in the detached HEAD state: 模块或工程路径 You can look around, make experimental changes and commit them, but be sure to checkout a branch not to lose your work. Otherwise you risk losing your changes. Read more about detached HEAD.

在模块或工程路径根目录下,Git Bash中:

git status

会显示:detached HEAD。即分离头,此时,本地工作区不在任何一个分支上,工作进展存储映射在一个改动ID上。

解决方法:

git branch

得到远程分支名称,比如master。

git checkout 远程分支名称

再次git status,会显示已经切换到了和远程分支同名的本地分支上,就可以成功地commit并push了。

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐