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

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

Next steps

For reference information, see 개인 계정 참조.