Snippet: use Github and Codeberg on the same machine with a single SSH key
- Set up Git and Github as per the Odin Project guide
- Set up Codeberg account and add the same SSH key to your profile
- Where you want to store your projects locally, create one folder for Github and one for Codeberg
- Create a .gitconfig file in each folder
- In each file, include
[user]
name = $YOUR USERNAME
email = $YOUR EMAIL
[init]
defaultBranch = main
[pull]
rebase = false
[core]
editor = code --wait
- Open again your global git settings
config --edit --global
- Update file to include
[includeIf "gitdir/i:~/YOURPATHTOGITHUB/Github/"]
path = ~/YOURPATHTOGITHUB/Github/.gitconfig
[includeIf "gitdir/i:~/YOURPATHTOCODEBERG/Codeberg/"]
path = ~/YOURPATHTOCODEBERG/Codeberg/.gitconfig
References and credits