gpt4 book ai didi

git: includeIf 不使用 git clone

转载 作者:行者123 更新时间:2023-12-04 02:32:35 27 4
gpt4 key购买 nike

.gitconfig :

[user]
name = Dr.jacky
email = personal.email@gmail.com
signingKey = ""
[includeIf "gitdir:/Users/drjacky/Projects/CompanyName/"]
path = /Users/drjacky/gitconfigcompanyname/.gitconfig
[core]
excludesfile = /Users/drjacky/.gitignore_global
autocrlf = input
[difftool "sourcetree"]
cmd = opendiff \"$LOCAL\" \"$REMOTE\"
path =
[mergetool "sourcetree"]
cmd = /Applications/Sourcetree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
trustExitCode = true
[commit]
template = /Users/drjacky/.stCommitMsg
gpgSign = false
[gpg]
program = gpg
[tag]
forceSignAnnotated = false

gitconfigcompanyname/.gitconfig :
[user]
name = My Name
email = my.company.email@company.com

.ssh/config :

# --- Sourcetree Generated ---
Host Personal-GitHub
HostName github.com
User Drjacky
PreferredAuthentications publickey
# IdentityFile /Users/drjacky/.ssh/Personal-GitHub
IdentityFile ~/.ssh/id_rsa
UseKeychain yes
AddKeysToAgent yes
# ----------------------------
# Company Work GitHub
Host github.com/Company
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_companyname
UseKeychain yes
AddKeysToAgent yes

我已经通过 ssh-add 添加了第二个 ssh pub .
现在,在终端/iTerm2 上,我重定向到 /Users/drjacky/Projects/CompanyName/HERE ,然后运行这个: git clone httpUrlOfMyCompanyRepogit clone sshOfMyCompanyRepo ;没关系,它没有访问权限:

remote: Repository not found.fatal: repository 'https://github.com/CompanyName/reponame.git/' not found


当我运行时 git config user.email , 在 CompanyName 文件夹路径下,它显示了我的个人电子邮件。
当我跑 git config --list :
credential.helper=osxkeychain
user.name=Dr.jacky
user.email=personal.email@gmail.com
user.signingkey=
includeif.gitdir:/Users/drjacky/Projectz/CompanyName/.path=/Users/drjacky/gitconfigcompanyname/.gitconfig
core.excludesfile=/Users/drjacky/.gitignore_global
core.autocrlf=input
difftool.sourcetree.cmd=opendiff "$LOCAL" "$REMOTE"
difftool.sourcetree.path=
mergetool.sourcetree.cmd=/Applications/Sourcetree.app/Contents/Resources/opendiff-w.sh "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED"
mergetool.sourcetree.trustexitcode=true
commit.template=/Users/drjacky/.stCommitMsg
commit.gpgsign=false
gpg.program=gpg
tag.forcesignannotated=false
(END)
git bugreport :
[System Info]
git version:
git version 2.28.0
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
uname: Darwin 19.6.0 Darwin Kernel Version 19.6.0: Sun Jul 5 00:43:10 PDT 2020; root:xnu-6153.141.1~9/RELEASE_X86_64 x86_64
compiler info: clang: 11.0.3 (clang-1103.0.32.62)
libc info: no libc information available
$SHELL (typically, interactive shell): /bin/zsh
备注 :
  • 我已经卸载了 SourceTree 但没有帮助。
  • git 版本 2.28.0
  • 使用工具成功克隆 repo 后,它可以正常工作,没有问题。

  • 更新:
    我检查了 Github 仪表板上的 SSH 部分,它显示根本没有使用 SSH key !
    enter image description here

    最佳答案

    我不得不改变 Host github.com/CompanyHost github.com-Companyssh/config .
    然后,像这样克隆:git clone git@github.com-Company:Company/repoName.git但是,还是希望有更好的解决方案,而不是更改 ssh 地址/HTTP URL。
    资料来源:

  • https://gist.github.com/jexchan/2351996
  • https://gist.github.com/jexchan/2351996#gistcomment-826728

  • 更新:
    根据这个 comment :
    个人 .gitconfig对于个人/其他所有项目:
    [user]
    name = Dr.jacky
    email = email@personal.com
    [core]
    sshCommand = ssh -i ~/.ssh/id_rsa -F /dev/null
    工作 .gitconfig对于公司项目:
    [user]
    name = Work Name
    email = work@company.com
    [core]
    sshCommand = ssh -i ~/.ssh/id_rsa_companyname -F /dev/null
    并更改了全局 .gitconfig对此:
    [user]
    name = Dr.jacky
    email = email@personal.com
    signingKey = ""
    [includeIf "gitdir:/Users/drjacky/*"]
    path = /Users/drjacky/gitconfigpersonal/.gitconfig
    [includeIf "gitdir:/Users/drjacky/Projectz/CompanyName/"]
    path = /Users/drjacky/gitconfigcompanyname/.gitconfig
    感谢 leddzip !

    关于git: includeIf 不使用 git clone,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63307136/

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