Snippet: use Github and Codeberg on the same machine with a single SSH key

  1. Set up Git and Github as per the Odin Project guide
  2. Set up Codeberg account and add the same SSH key to your profile
  3. Where you want to store your projects locally, create one folder for Github and one for Codeberg
  4. Create a .gitconfig file in each folder
  5. In each file, include
    [user]
    name = $YOUR USERNAME
    email = $YOUR EMAIL
    [init]
    defaultBranch = main
    [pull]
    rebase = false
    [core]
    editor = code --wait
  6. Open again your global git settings
    config --edit --global
  7. 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