gpt4 book ai didi

gitconfig 忽略 includeIf

转载 作者:行者123 更新时间:2023-12-05 03:27:30 27 4
gpt4 key购买 nike

我正在尝试设置我的 git 配置,以便我可以使用工作环境和个人环境。

这是我的 ~.gitconfig 文件的内容(碰巧 work 和 private 在 github 上):

 [url "git@github.com:"]
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 = workerID@company.com
name = realname
signingkey = 454684684654...
[commit]
gpgSign = true

> cat ~/.gitconfig-private
[user]
email = fzd@email.com
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 配置上有一种缓存吗?

[编辑]以下是我的 ~/.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

我确实有一个私有(private)存储库的 key 对,我不完全确定如何在此处同时拥有这两个 key 。可能类似于 this .

最佳答案

includeIf 仅适用于 ~/go/src/github.com/work/~/go/下的repositories src/github.com/fzd/ 但不在非 repo 目录中。

测试:

cd ~/go/src/github.com/work/<some-repo>
git config --get user.email

关于gitconfig 忽略 includeIf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71473679/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com