git detected dubious ownership in repository(idea gitlab不能使用账户密码登录)

1.情景展示

如上图所示,当我在idea当中commit时,报错信息如下:

Error updating changes: detected dubious ownership in repository at 'D:/workspace-idea2024/dc' 'D:/workspace-idea2024/dc' is owned by: (inconvertible) (S-1-5-21-269100500-990079634-2360623121-1000) but the current user is: DESKTOP-CLJBLSF/Marydon (S-1-5-21-46963430-3283040697-1052111559-1001) To add an exception for this directory, call:  git config --global --add safe.directory D:/workspace-idea2024/dc

2.具体分析

出现这种情况是因为:

我在重装系统的时候格式化了系统盘,这导致idea在系统盘(通常是C盘)的配置随着消失。

而我们的项目存储的git信息(存储在项目的.git目录下)却没有变化。

3.解决方案

这个问题也好解决,错误信息提示已经给了我们明确的git指令。

git config --global --add safe.directory 项目目录所在的绝对路径

我们打开idea的terminal窗口,运行如下命令。

前提:已经配置了git环境变量。

这个时候,打开git视图,点击任意一个分支就能看到git历史提交记录了。

重新添加git账户

点击“添加账户”,发现只能通过token登录。

不能通过账户、密码的方式登录。

我们需要将gitLab插件禁用掉。

然后再去同步代码的时候就会出现登录界面啦。

写在最后

  哪位大佬如若发现文章存在纰漏之处或需要补充更多内容,欢迎留言!!!

 相关推荐:

posted @ 2024-05-28 19:38  Marydon  阅读(51)  评论(0编辑  收藏  举报