我正在處理多個專案,這些專案連接到不同的 github 帳戶。我的主要專案的配置是使用設定git config --global user.name "firstusername"的,第二個專案使用的是git config user.name "secondusername". 但是當我嘗試使用 將第二個連接到 githubgit push -u origin main時,它說Permission to secondusername/secondusername.github.io.git denied to firstusername。
當我在第二個專案檔案夾上打開 gitbash 并運行git config user.name它時,它會給出secondusername,但是當我運行git config --list --show-origin憑據時會這樣說
...
file:C:/Users/home/.gitconfig user.name=firstusername
file:C:/Users/home/.gitconfig [email protected]
...
但是當我檢查secondproject/.git/config檔案時,內容看起來像這樣
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
[user]
name = secondusername
email = [email protected]
[remote "origin"]
url = https://github.com/secondusername/secondusername.github.io.git
fetch = refs/heads/*:refs/remotes/origin/*
我究竟做錯了什么??
uj5u.com熱心網友回復:
user.name并且僅用于在您在本地 repo ( , , , ...)user.email上創建提交時寫入作者和/或提交者的姓名。git commitgit mergegit rebase
另一方面,連接到遠程服務的憑據應該通過遠程的 url 以某種方式提供。
嘗試將第二個 repo 的遠程 url 更改為:https://[email protected]/seconduser/...
另一種方法是通過 ssh 訪問 github,并設定您的本地作業站(ssh_config特別是它)以便能夠輕松地定位兩個帳戶:
多個 GitHub 帳戶和 SSH 配置
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/446815.html
上一篇:在不使用SSL的情況下為私有GitHub存盤庫設定用戶?
下一篇:Git個人訪問令牌快取
