multiple accounts
[!TIP|label: Multiple Accounts]
work
John Doe
john@work.com
~/.ssh/work_ed25519
git@github.com:work/*
service account
jenkins
jenkins@work.com
~/.ssh/jenkins_ed25519
git@github.com:company/*
personal
John Doe
john@personal.com
~/.ssh/personal_ed25519
git@github.com:john/*
~/.gitconfig.d/accounts/<account>is used to distinguish accounts and emails
~/.gitconfig.d/.gitconfigis used to distinguish the git remote URLs byincludeIf hasconfig:remote.*.url
~/.ssh/config.d/githubis used to distinguish the ssh key by host-alias
[!NOTE]
to check git the git clone debug log via:
GIT_TRACE=true GIT_CURL_VERBOSE=true GIT_TRACE_PACK_ACCESS=true GIT_TRACE_SETUP=true GIT_TRACE_SHALLOW=true \ git clone <repo-url>
check more details in * iMarslo - troubleshooting
with ssh
gitconfig
ssh config
~/.ssh/config.d/github[!TIP] the HOST name alias should matches to the URL in gitconfig
~/.ssh/config[!TIP]
put the include in the beginning of the
~/.ssh/configfile
with https
[!NOTE]
prepare PAT for 3 accounts in Personal Access Tokens (classic) or Fine-grained personal access tokens
TOKEN TYPE
GIT OPERATIONS
(clone/push)
GIT LFS UPLOAD/DOWNLOAD
GITHUB ACTIONS (WORKFLOW)
semantic-release
GITHUB API (REST/GRAPHQL)
PRIVATE SUBMODULES
GITHUB CLI (GH)
NOTES
Fine-grained PAT
β
β Fails (LFS lock verification denied)
β
β
β
β
β οΈ Partially supported
Secure and scoped, but limited in CLI/automation contexts like Git LFS
Classic PAT
β
β
β
β
β
β
β
Recommended for CLI tools, LFS, CI/CD, automation, and broad API access
gitconfig
setup .git-credentials
git hook and alias
[!NOTE]
setup the
~/.git-templatedirectory as the template directory for git
[!TIP]
~/.git-templates/set-git-user.shwill be using for bothpost-checkouthook and git alias
git hook
[!TIP]
the
post-checkouthook will be triggered after agit checkoutcommand. it will set the git user name and email based on the remote URL automaticallyverify by:
git alias
Last updated
Was this helpful?