Skip to main content

Managing multiple accounts

If you use one workstation to contribute to projects for more than one account, you can modify your Git configuration to simplify the contribution process.

Platform navigation

About management of multiple accounts

In some cases, you may need to use multiple accounts on GitHub. For example, you may have a personal account for open source contributions, and your employer may also create and manage a user account for you within an enterprise.

You cannot use a 관리형 사용자 계정 to contribute to public projects on GitHub.com, so you must contribute to those resources using your personal account. For more information, see About Enterprise Managed Users in the GitHub Enterprise Cloud documentation.

If you need to use multiple accounts, you can stay signed in to your accounts and switch between them. For example, switching between a personal account and a service account. For more information, see 계정 간 전환.

If you want to use one workstation to contribute from both accounts, you can simplify contribution with Git by using a mixture of protocols to access repository data, or by using credentials on a per-repository basis.

경고

Be mindful when you use one workstation to contribute to two separate accounts. Management of two or more accounts can increase the chance of mistakenly leaking internal code to the public.

If you aren't required to use a 관리형 사용자 계정, GitHub recommends that you use one personal account for all your work on GitHub.com. With a single personal account, you can contribute to a combination of personal, open source, or professional projects using one identity. Other people can invite the account to contribute to both individual repositories and repositories owned by an organization, and the account can be a member of multiple organizations or enterprises.

Contributing to two accounts using HTTPS and SSH

If you contribute with two accounts from one workstation, you can access repositories by using a different protocol and credentials for each account.

Git can use either the HTTPS or SSH protocol to access and update data in repositories on GitHub. The protocol you use to clone a repository determines which credentials your workstation will use to authenticate when you access the repository. With this approach to account management, you store the credentials for one account to use for HTTPS connections and upload an SSH key to the other account to use for SSH connections.

You can find both the HTTPS or an SSH URLs for cloning a repository on the repository's page. For more information, see 리포지토리 복제.

For more information about the use of SSH to access repositories, see SSH를 통한 GitHub 연결.

Contributing to multiple accounts using HTTPS and personal access tokens

Alternatively, if you want to use the HTTPS protocol for both accounts, you can use different personal access tokens for each account by configuring Git to store different credentials for each repository.

  1. 터미널을 엽니다.

  2. 자격 증명 관리자의 사용을 확인하려면 다음 명령을 입력하고 출력을 확인합니다.

    Shell
    git config --get credential.helper
    
  3. 출력에서 자격 증명 관리자를 사용하고 있음을 확인하는 경우 자격 증명 관리자에 대해 저장된 자격 증명을 지웁니다.

    • 출력에 자격 증명 관리자의 이름이 포함되지 않으면 구성된 자격 증명 관리자가 없는 것입니다. 따라서 다음 단계를 진행할 수 있습니다.

    • If the output is osxkeychain, you're using the macOS keychain. To clear the credentials, you can use the credential helper on the command line:

      $ git credential-osxkeychain erase
      host=github.com
      protocol=https
      > [Press Return]
      >
      
    • 출력이 manager인 경우(이전 버전에서는 manager-core) Git 자격 증명 관리자를 사용하는 것입니다. 자격 증명을 지우려면 다음 명령을 실행합니다.

      Shell
      echo "protocol=https\nhost=github.com" | git credential-manager erase
      
  4. GitHub에서 액세스하는 각 리포지토리의 전체 원격 URL에 대한 자격 증명을 캐시하도록 Git을 구성하려면 다음 명령을 입력합니다.

    Shell
    git config --global credential.https://github.com.useHttpPath true
    
  5. 각 계정에 대해 repo 범위가 있는 전용 personal access token (classic)을(를) 만듭니다. 또는 각 계정 및 구성원인 각 조직에 대해 원하는 리포지토리에 액세스할 수 있고 리포지토리 콘텐츠에 대한 읽기 및 쓰기 권한이 있는 fine-grained personal access token을 만듭니다. 자세한 내용은 개인용 액세스 토큰 관리을(를) 참조하세요.

  6. Git을 사용하여 리포지토리를 복제하거나 이미 복제한 리포지토리의 데이터에 액세스할 때 처음으로 Git에서 자격 증명을 요청합니다. 리포지토리에 액세스할 수 있는 계정의 personal access token을(를) 제공합니다.

    Git이 리포지토리의 전체 원격 URL을 기반으로 personal access token을(를) 캐시할 것이며, 그러면 올바른 계정을 사용하여 GitHub.com에서 리포지토리 데이터에 액세스하고 쓸 수 있습니다.

  1. Open Git Bash.

  2. 자격 증명 관리자의 사용을 확인하려면 다음 명령을 입력하고 출력을 확인합니다.

    Shell
    git config --get credential.helper
    
  3. 출력에서 자격 증명 관리자를 사용하고 있음을 확인하는 경우 자격 증명 관리자에 대해 저장된 자격 증명을 지웁니다.

    • 출력에 자격 증명 관리자의 이름이 포함되지 않으면 구성된 자격 증명 관리자가 없는 것입니다. 따라서 다음 단계를 진행할 수 있습니다.
    • 출력이 manager인 경우(이전 버전에서는 manager-core) Git 자격 증명 관리자를 사용하는 것입니다. 자격 증명을 지우려면 다음 명령을 실행합니다.
    Shell
    echo "protocol=https`nhost=github.com" | git credential-manager erase
    
    • If the output is wincred, you're using the Windows Credential Manager. To clear the credentials, enter the following command.

      Shell
      cmdkey /delete:LegacyGeneric:target=git:https://github.com
      
  4. GitHub에서 액세스하는 각 리포지토리의 전체 원격 URL에 대한 자격 증명을 캐시하도록 Git을 구성하려면 다음 명령을 입력합니다.

    Shell
    git config --global credential.https://github.com.useHttpPath true
    
  5. 각 계정에 대해 repo 범위가 있는 전용 personal access token (classic)을(를) 만듭니다. 또는 각 계정 및 구성원인 각 조직에 대해 원하는 리포지토리에 액세스할 수 있고 리포지토리 콘텐츠에 대한 읽기 및 쓰기 권한이 있는 fine-grained personal access token을 만듭니다. 자세한 내용은 개인용 액세스 토큰 관리을(를) 참조하세요.

  6. Git을 사용하여 리포지토리를 복제하거나 이미 복제한 리포지토리의 데이터에 액세스할 때 처음으로 Git에서 자격 증명을 요청합니다. 리포지토리에 액세스할 수 있는 계정의 personal access token을(를) 제공합니다.

    Git이 리포지토리의 전체 원격 URL을 기반으로 personal access token을(를) 캐시할 것이며, 그러면 올바른 계정을 사용하여 GitHub.com에서 리포지토리 데이터에 액세스하고 쓸 수 있습니다.

  1. 터미널을 엽니다.

  2. 자격 증명 관리자의 사용을 확인하려면 다음 명령을 입력하고 출력을 확인합니다.

    Shell
    git config --get credential.helper
    
  3. 출력에서 자격 증명 관리자를 사용하고 있음을 확인하는 경우 자격 증명 관리자에 대해 저장된 자격 증명을 지웁니다.

    • 출력에 자격 증명 관리자의 이름이 포함되지 않으면 구성된 자격 증명 관리자가 없는 것입니다. 따라서 다음 단계를 진행할 수 있습니다.
    • 출력이 manager인 경우(이전 버전에서는 manager-core) Git 자격 증명 관리자를 사용하는 것입니다. 자격 증명을 지우려면 다음 명령을 실행합니다.
    Shell
    echo "protocol=https\nhost=github.com" | git credential-manager erase
    
  4. GitHub에서 액세스하는 각 리포지토리의 전체 원격 URL에 대한 자격 증명을 캐시하도록 Git을 구성하려면 다음 명령을 입력합니다.

    Shell
    git config --global credential.https://github.com.useHttpPath true
    
  5. 각 계정에 대해 repo 범위가 있는 전용 personal access token (classic)을(를) 만듭니다. 또는 각 계정 및 구성원인 각 조직에 대해 원하는 리포지토리에 액세스할 수 있고 리포지토리 콘텐츠에 대한 읽기 및 쓰기 권한이 있는 fine-grained personal access token을 만듭니다. 자세한 내용은 개인용 액세스 토큰 관리을(를) 참조하세요.

  6. Git을 사용하여 리포지토리를 복제하거나 이미 복제한 리포지토리의 데이터에 액세스할 때 처음으로 Git에서 자격 증명을 요청합니다. 리포지토리에 액세스할 수 있는 계정의 personal access token을(를) 제공합니다.

    Git이 리포지토리의 전체 원격 URL을 기반으로 personal access token을(를) 캐시할 것이며, 그러면 올바른 계정을 사용하여 GitHub.com에서 리포지토리 데이터에 액세스하고 쓸 수 있습니다.

Contributing to multiple accounts using SSH and GIT_SSH_COMMAND

If you want to use the SSH protocol for both accounts, you can use different SSH keys for each account. For more information about using SSH, see SSH를 통한 GitHub 연결.

To use a different SSH key for different repositories that you clone to your workstation, you must write a shell wrapper function for Git operations. The function should perform the following steps.

  1. Determine the repository's full name with owner, using a command such as git config --get remote.origin.url.
  2. Choose the correct SSH key for authentication.
  3. Modify GIT_SSH_COMMAND accordingly. For more information about GIT_SSH_COMMAND, see Environment Variables in the Git documentation.

For example, the following command sets the GIT_SSH_COMMAND environment variable to specify an SSH command that uses the private key file at PATH/TO/KEY/FILE for authentication to clone the repository named OWNER/REPOSITORY on GitHub.com.

Shell
GIT_SSH_COMMAND='ssh -i PATH/TO/KEY/FILE -o IdentitiesOnly=yes' git clone git@github.com:OWNER/REPOSITORY