Skip to content

Instantly share code, notes, and snippets.

@1natsu172
Last active April 18, 2020 11:00
Show Gist options
  • Save 1natsu172/70a741781e78d80299f283a6af4f3ba6 to your computer and use it in GitHub Desktop.
Save 1natsu172/70a741781e78d80299f283a6af4f3ba6 to your computer and use it in GitHub Desktop.
https時代のgitアカウントを使い分ける方法 ref: https://qiita.com/1natsu172/items/a4a3357a0481440ec6a5
host github.com-main
HostName github.com
IdentityFile ~/.ssh/id_rsa_github
User git
host github.com-sub
HostName github.com
IdentityFile ~/.ssh/id_rsa_github_sub
User git
$ git clone git@github.com-main:username/repo.git
$ git credential-osxkeychain
Usage: git credential-osxkeychain <get|store|erase>
$ git clone https://hitonatsu@gitlab.com/1natsu172/example-private-repo.git
$ git clone https://hitonatsu@gitlab.com/1natsu172/example-private-repo.git
Password for 'https://hitonatsu@gitlab.com':
$ git remote -v
origin https://hitonatsu@gitlab.com/1natsu172/example-private-repo.git (fetch)
origin https://hitonatsu@gitlab.com/1natsu172/example-private-repo.git (push)
$ GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa_example -F /dev/null" git clone example
$ git config core.sshCommand "ssh -i ~/.ssh/id_rsa_example -F /dev/null"
$ git config --global user.name "Mona Lisa"
$ git config --global user.email "email@example.com"
$ git config --local user.name "Mona Lisa"
$ git config --local user.email "email@example.com"
export GIT_COMMITTER_NAME="Mona Lisa"
export GIT_COMMITTER_EMAIL="email@example.com"
export GIT_AUTHOR_NAME="Mona Lisa"
export GIT_AUTHOR_EMAIL="email@example.com"
$ git clone https://gitlab.com/1natsu172/example-public-repo.git
$ git clone https://gitlab.com/1natsu172/example-private-repo.git
Username for 'https://gitlab.com':
Password for 'https://gitlab.com':
$ git config --global credential.helper osxkeychain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment