【发布时间】:2022-01-29 18:28:11
【问题描述】:
刚接触 git,正在尝试学习在线课程,但我的 ubuntu 的行为与老师的不同。我在 stackoverflow 和其他网站上搜索了我的错误。我发现了类似的问题,但不是同一个问题。没有一个答案对我有帮助,所以我提出了这个新问题。
在我的本地仓库中,当我输入“git init”时,我得到:
error: chmod on /mnt/c/users/jds/documents/projects/testrepo/.git/config.lock failed: Operation not permitted
fatal: could not set 'core.filemode' to 'false'
但是,在文件夹中(如文件资源管理器中所示)我可以看到 .git 文件已创建。
如果我然后运行“git status”命令,我会得到:
fatal: not a git repository (or any parent up to mount point /mnt)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
我在 Windows 10 上,在适用于 Linux 的 Windows 子系统中运行它。
----------------- 更新 ------------------
我删除了 .git 文件并以 root 用户身份重新启动了 ubuntu。以root用户执行上述命令时,它起作用了:
root@LAPTOP-ILK7ETOO:/mnt/c/users/jds/documents/projects/testrepo# git 初始化
在中初始化空的 Git 存储库 /mnt/c/users/jds/documents/projects/testrepo/.git/
root@LAPTOP-ILK7ETOO:/mnt/c/users/jds/documents/projects/testrepo# git 状态
在主分支上
还没有提交
无需提交(创建/复制文件并使用“git add”进行跟踪)
root@LAPTOP-ILK7ETOO:/mnt/c/users/jds/documents/projects/testrepo#
但为什么我不能以指定用户的身份执行此操作?我使用“ls -l”检查了权限,并且 testrepo 启用了完全权限:
drwxrwxrwx 1 root root 512 Jan 29 18:06 testrepo
【问题讨论】:
-
仅供参考,称其为“.git 文件”令人困惑。 Git repo 有一个
.git目录,而不是.git文件。 -
1.这不是与 git 相关的问题 2。这不是 SO 的问题
-
它告诉您失败的原因以及失败的文件,但您没有查找失败的操作或查看失败的文件的权限。您知道如何查看权限,忽略了它告诉您的内容并完全去其他地方寻找。这看起来不像是在努力理解。
标签: windows git ubuntu windows-subsystem-for-linux