Skip to content

Instantly share code, notes, and snippets.

@tomsiwik
Created September 26, 2024 21:52
Show Gist options
  • Save tomsiwik/fb74b901cb81d2d3ba40c94dc7292cfe to your computer and use it in GitHub Desktop.
Save tomsiwik/fb74b901cb81d2d3ba40c94dc7292cfe to your computer and use it in GitHub Desktop.
Multi-Account Repo Setup
[includeIf "gitdir:~/Code/org-1/"]
path = ~/Code/org-1/.gitconfig
[includeIf "gitdir:~/Code/org-2/"]
path = ~/Code/org-2/.gitconfig
[includeIf "gitdir:~/Code/acc-2/"]
path = ~/Code/acc-2/.gitconfig
[user]
name = Account One
email = [email protected]
[core]
sshCommand = "ssh -i ~/.ssh/acc-1-or-org-1-priv-key.github.id_ed25519"

Clone anything related to org or acc subfolders

# Make sure your github acc has your pub key and ~/.ssh/ has your priv key - correctly chmod
cd ~/Code/org-1/

git clone [email protected]:org-1/somerepo.git
# ...
# > remote: Resolving deltas: 100% (4/4), completed with ... local objects.
# Success

# Let's check which acc the repo will use for commits etc
cd somerepo/

git config --get user.name
# > Account One
git config --get user.email
# > [email protected]

Enjoy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment