Git fatal unable to auto-detect email address

WechatIMG1442.jpeg

場景

實現 Git Gitee倉庫自動部署,使用 www-data 用戶拉取代碼時,每次都要設置全局 git 用戶信息。

錯誤

$ cat /var/log/webhooks.log
From gitee.com:xoncology/shjyzxk
 * branch            zhangyuhai -> FETCH_HEAD
warning: unable to access '/root/.config/git/attributes': Permission denied
*** Please tell me who you are.
Run
  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'www-data@iZuf68boltvbz79cxbsunfZ.(none)')

查看 webhooks 日志文件,返回fatal: unable to auto-detect email address。

解決

  • 查看當前項目 git 信息
$ git config --local -l
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=git@gitee.com:xoncology/shjyzxk.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
branch.test.remote=origin
branch.test.merge=refs/heads/test

看到并沒有全局用戶信息。

  • 設置全局用戶信息
$ git config --global user.email "you@domain.com" && git config --global user.name "dev"

執(zhí)行上面命令設置后,還是不能成功拉取。

  • 直接替換全局用戶信息
$ git config --replace-all user.email "you@domain.com" && git config --replace-all user.name "github_username"
  • 再次查看當前項目 git 信息
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=git@gitee.com:xoncology/shjyzxk.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
branch.test.remote=origin
branch.test.merge=refs/heads/test
user.email=you@domain.com
user.name=github_username

看到已成功返回全局用戶信息,再次嘗試提交代碼,服務器可以自動拉取。

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。
禁止轉載,如需轉載請通過簡信或評論聯系作者。

友情鏈接更多精彩內容