我在 AWS EC2 上使用 Ubuntu 22.04,git 版本 2.34.1
下面是我的~/.gitconfig檔案:
[credential "https://github.com"]
helper =
helper = !/usr/bin/gh auth git-credential
[credential "https://gist.github.com"]
helper =
helper = !/usr/bin/gh auth git-credential
[safe]
directory = /var/www/html/wix
directory = /var/www/html/wix-native-app
[user]
name = JXX XXXha
email = [email protected]
signingkey = 8XXXXXXXXXXX1
[commit]
gpgsign = true
但是,當我嘗試提交時,出現以下錯誤:
ubuntu@ip-172-31-46-106:/var/www/html/wix-native-app$ sudo git commit
Author identity unknown
*** Please tell me who you are.
Run
git config --global user.email "[email protected]"
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: no email was given and auto-detection is disabled
但正如我的.gitconfig檔案中所見,用戶名和電子郵件已經設定。在配置中是否還有其他事情要做才能提交作業?
uj5u.com熱心網友回復:
sudo您正在以用戶身份執行 git root。因此 git 將在 中查找配置/root/.gitconfig,而您將配置設定為~/.gitconfigie 在非特權用戶的主路徑中。
你有兩個選擇:
更改權限和/或所有權,
/var/www/html/wix-native-app以便您的非特權用戶ubuntu有權讀取和寫入此路徑。確保包含-R在您的chmod/chgrp命令中以將更改應用于所有檔案和子檔案夾。優點:
- 您不需要特權用戶來更改 Web 服務器的內容。有權更改內容的用戶不會獲得篡改服務器配置的權限。
- 您可以使用組將權限分配給多個用戶。
- 如果您有不同的用戶負責 的不同子檔案夾
/var/www/html/,您可以為他們分配僅對他們負責的檔案夾的寫入權限。
將您的復制
~/.gitconfig到/root/.gitconfiggit 將找到配置,如果您運行它 sudo'ed。缺點:
- 在大多數情況下,您不應將更改 Web 服務器內容視為需要特權帳戶的管理任務。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/488200.html
上一篇:如何將git中的一個分支變基更接近另一個分支的頭部?
下一篇:如何將樹狀結構“提取”到目錄中?
