Windows 連 Synology NAS 建 Git Repo:git 出現 dubious ownership 錯誤
我在 Windows 用網路位置連上我的 NAS,然後建立了一個 git repo。
正當我要 git commit 的時候,出現了錯誤:
Failed to get UnRev file list
fatal: detected dubious ownership in repository at '//NAS/_'
To add an exception for this directory, call:
git config --global --add safe.directory '%(prefix)///NAS/_'
Set the environment variable GIT_TEST_DEBUG_UNSAFE_DIRECTORIES=true and run again for more information.
我一開始腦補成「Git 沒有該資料夾權限」之類的(懶得看錯誤訊息 🙈), 後來才發現是 Git 認為該 repo 的擁有者/路徑不安全(dubious ownership)。
解法就是把該路徑加入白名單:
git config --global --add safe.directory "%(prefix)///MyNAS/_"
列出所有白名單:
git config --get-all safe.directory
白名單會寫入使用者目錄下的 .gitconfig:
%USERPROFILE%\.gitconfig
.gitconfig 範例如下:
[user]
name = Peter
email = peter@mail.com
[safe]
directory = %(prefix)///MyNAS/工作日誌
directory = %(prefix)///MyNAS/_
版本/修改異動
2025-12-19 v1.0
- 初版
- 由 ChatGPT 調整 HTML 內文樣式
留言
張貼留言