背景
- 複数のAWSアカウントのcodecommitを利用している
- HTTPSでcodecommitのリポジトリにgitで接続する時に、事前に認証情報を保存しておくと、同じドメインで複数の認証情報を登録すると、以下のエラーが起こる
% git pull
fatal: repository 'https://git-codecommit.ap-northeast-1.amazonaws.com/v1/repos/xxxxxxx/' not found
対策1- Mac OS X のパスワード管理
- パスワードの管理方式を設定する
git config --global credential.helper osxkeychain
- プロジェクトにgit設定
Cd path/to/project
git config --local credential.https://git-codecommit.ap-northeast-1.amazonaws.com.username <YOUR USERNAME>
- git pull実施をして、パスワードを入力して正常に使える
% git pull
Password for 'https://username@git-codecommit.ap-northeast-1.amazonaws.com':/v1/repos/xxxxxx/
- パスワード保存場所
- キーチェーンアクセスアプリ
- ログイン -> gitで検索する
- git-codecommit.ap-northeast-1.amazonaws.comを押す
- Usernameとpasswordをみえる
対策2 - ファイルに保存
- パスワードの管理方式を設定する
git config --global credential.helper store
- プロジェクトにgit設定
Cd path/to/project
git config --local credential.https://git-codecommit.ap-northeast-1.amazonaws.com.username <YOUR USERNAME>
- git pull実施
% git pull
Password for 'https://username@git-codecommit.ap-northeast-1.amazonaws.com':/v1/repos/xxxxxx/
- パスワードを入力して正常に使える
- ユーザネームとパスワード保存場所
- ~/.git-credentials
- デメリット
- パスワードが平文が保存される