TECH
BLOG

Use multiple GitHub accounts with HTTPS on Windows

2020
5

beginning

To use multiple GitHub accounts properly, there is a way to SSH into one account. However, since Git LFS files on GitHub are only HTTPS and cannot be SSH, they cannot be downloaded. Therefore, I use multiple accounts properly with HTTPS in the Credential Manager namespace.

Required environment

Git for WindowsCheck Enable Git Credential Manager in the installation wizardCredential Manager for GitWe will install them together.

image.png

Set up your main account

No special settings are required. If you authenticate by performing a git clone or the like, git: https://github.comが追加されます will be the Windows credentials in the credential manager in the control panel.

image.png

Sub-account settings

If you set a namespace in Credential Manager, the git: at the beginning of the credentials will change, and you can use multiple accounts properly.

  1. When cloning, the namespace is not set, so specify it with -c credential.namespace. The name you specify can be any alphanumeric character other than git.
  2. git -c credential.namespace=sub clone https://github.com/[name]/[repository].git
  3. A dialog will appear, so enter your sub-account account and password.
  4. Once cloned, set credential.namespace to the local config.
  5. cd [repository]
    git config credential.namespace sub
  6. Push and make sure it doesn't fail.
  7. Git push

If you clone and open the credential manager after the authentication has passed, sub: https://github.comが追加されています.

image.png

For details, see Credential Manager for Windowscredential.namespaceSee.

Points to note

Git config'sConditional IncludesIf you use it, it seems that credential.namespace can be set to the folder specified by gitdir:, but since Credential Manager does not support Conditional Includes, it cannot be used. I've submitted a request to issues, so if you're interested, please respond and comment.

Reference links

RELATED PROJECT

No items found.