我正在嘗試設定我的 git 配置,以便我可以使用作業環境和個人環境。
這是我的~.gitconfig檔案的內容(它恰好在 github 上作業和私有):
[url "[email protected]:"]
insteadOf = https://github.com/
[core]
editor = vim
[includeIf "gitdir:~/go/src/github.com/work/"]
path = ~/.gitconfig-work
[includeIf "gitdir:~/go/src/github.com/fzd/"]
path = ~/.gitconfig-private
這是兩個檔案的內容:
> cat ~/.gitconfig-work
[user]
email = [email protected]
name = realname
signingkey = 454684684654...
[commit]
gpgSign = true
> cat ~/.gitconfig-private
[user]
email = [email protected]
name = fzd
現在讓我們漫游到這些目錄之一:
> cd ~/go/src/github.com/work/
> git config --get user.email
>
> cd ~/go/src/github.com/fzd/
> git config --get user.name
>
以上均未回傳字串。
我期待這能作業(它會解決我麻煩的 git 配置)。
現在,“有趣”的部分:這個配置最初是我的作業配置,只有作業設定正確。當我嘗試從 github 克隆一個 repo 時,無論我在哪里,它都在使用我的作業設定(自從我嘗試弄亂 git 后我還沒有重新啟動 - 我想這還不值得)。
誰能告訴我我的配置做錯了什么?為什么要使用作業引數?git config 上是否有某種快取?
[編輯] 這是我的~/.ssh/config檔案的內容:
Host github.com
Hostname ssh.github.com
Port 443
Host *
ServerAliveInterval 10
AddKeysToAgent yes
IgnoreUnknown UseKeychain
UseKeychain yes
IdentityFile ~/.ssh/id_ed25519_work
我確實有一個私人回購的密鑰對,我不完全確定如何在這里擁有兩者。大概是這樣的。
uj5u.com熱心網友回復:
includeIf僅適用于非 repo 目錄下的存盤庫~/go/src/github.com/work/,~/go/src/github.com/fzd/但不適用于非 repo 目錄。
去測驗:
cd ~/go/src/github.com/work/<some-repo>
git config --get user.email
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/443655.html
