Categories
Development

Multiple git accounts: no .ssh/config or SSH agent

I’d like to use multiple Git server accounts (with any of GitHub, GitLab, BitBubket etc.).

The accounts are distinguished by their email addresses, name1@email1.com and
name2@email2.org and git is setup to use these addresses in the relevant
repositories

The following constraints apply to the ‘change-account workflow’:

  1. Without touching/changing SSH config files (e.g. ~/.ssh/config, etc.) when
    repositories or servers are added/removed/changed.
  2. Without requiring SSH agent running i.e. no ssh-add ....
  3. Without changing environment variables.
  4. Without changing the git clone <address> instruction.
  5. Use the same ‘change-account workflow’ across all private and public repositories.
  6. The ‘change-account workflow’ is a one (1) step/command.
  7. The ‘change-account workflow’ is one (1) time per repository (i.e. not each
    time you move into work on the repository).

The initial repository setup (which is also one time activity) can involve more than
one step.
Any conventions/assumptions are acceptable as long as they don’t break the
constraints.

Unrelated questions:

These are responses that do not satisfy the constraints.
They generally require changes to ~/.ssh/config and/or involve the SSH agent daemon:

  1. handle-multiple-git-account
  2. using-multiple-git-accounts
  3. multiple-git-accounts-and-ssh-key
  4. multiple-github-accounts-ssh-config
  5. multiple-git-users-on-same-machine
  6. multiple-github-accounts-with-git-in-windows
  7. multiple-github-accounts-on-the-same-computer
  8. git-multiple-accounts-and-repository-problems
  9. ssh-config-to-access-multiple-repo-not-working
  10. can-i-specify-multiple-users-for-myself-in-gitconfig
  11. multiple-github-accounts-on-the-same-computer
  12. how-can-i-push-git-with-multiple-accounts-on-one-machine
  13. setting-up-ssh-config-file-for-multiple-codebase-accounts
  14. how-to-configure-multiple-github-accounts-on-your-computer
  15. multiple-github-accounts-what-values-for-host-in-ssh-config
  16. ssh-config-with-multiple-keys-for-multiple-gitlab-user-accounts
  17. github-multiple-accounts-permission-to-personalusername-reponame-git-denied-to

Leave an answer

Your email address will not be published. Required fields are marked *