[英]Why in my local repo, "git init" throws a fatal error, but is still creating the .git file? Then, "git status" returns fatal error "not a git repo"?
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).
這是我的 ubuntu 終端,在后台使用 Windows 文件資源管理器(顯示已在 repo 中創建了 .git 文件)
我在 Windows 10 上,在 Linux 的 Windows 子系統中運行它。
- - - - - - - - - 更新 - - - - - - - - -
我刪除了.git文件並以root用戶身份重新啟動ubuntu。 以 root 用戶身份執行上述命令時,它起作用了:
root@LAPTOP-ILK7ETOO:/mnt/c/users/jds/documents/projects/testrepo# git init
在 /mnt/c/users/jds/documents/projects/testrepo/.git/ 中初始化空 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
為什么我不能以指定用戶的身份執行此操作?
因為您的非 root 用戶不能chmod
文件,如錯誤消息中所寫。 並且“如何修復它”超出了 SO 的 scope
PS - 現有的.git
目錄不是功能性 Git 存儲庫的標志
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.