.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
I've added the second ssh pub via ssh-add
.
Now, on the terminal/iTerm2, I redirect to /Users/drjacky/Projects/CompanyName/HERE
, then run this:
git clone httpUrlOfMyCompanyRepo
or git clone sshOfMyCompanyRepo
; Doesn't matter, it doesn't have access:
remote: Repository not found. fatal: repository 'https://github.com/CompanyName/reponame.git/' not found
And when I run git config user.email
, under CompanyName folder path, it shows my personal email.
When I run 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
Notes:
- I've uninstalled SourceTree but didn't help.
- git version 2.28.0
- After cloning the repo with a tool successfully, it works with the correct without a problem.
Update: I've check SSH section on Github dashboard, and it shows the SSH key has not been used at all!