解决Git的detached HEAD问题
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 los
文章共160字 · 阅读需要大约1分钟
一键AI生成摘要,助你高效阅读
问答
·
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了。
更多推荐
已为社区贡献5条内容
所有评论(0)