LoginSignup
1
2

More than 5 years have passed since last update.

git config の設定が想定した内容にならなかった

Posted at

以下のドキュメントにあるようにクロスアカウント設定のための git config --global credential.helperを実行したが想定した設定内容にならず、git clone で失敗。

クロスアカウントアクセス: AccountB のリポジトリユーザー用アクション

$git config --global credential.helper "!aws codecommit credential-helper --profile MyCrossAccountAccessProfile $@"

$git clone https://git-codecommit.ap-northeast-1.amazonaws.com/v1/repos/xxxx
Cloning into 'xxxx'...
git: 'credential-aws' is not a git command. See 'git --help'.

$cat .gitconfig
[credential]
        helper = "aws --profile MyCrossAccountAccessProfile codecommit list-repositories --region ap-northeast-1 codecommit credential-helper --profile MyCrossAccountAccessProfile "

となり、.gitconfig がおかしい
本当は以下のドキュメントにあるように以下のようになって欲しい。

[credential]    
    helper = !aws codecommit credential-helper --profile=CodeCommitProfile $@ 
    UseHttpPath = true 

これは設定したのが Bash だったので展開されてしまったためようだった。

What is $@ in Bash? [duplicate]

実は CodeCommit のドキュメントにも記載があったのだが、二重引用符ではなく単一引用符を使用すれば OK.

$git config --global credential.helper '!aws codecommit credential-helper --profile MyCrossAccountAccessProfile $@'

ステップ 3: 認証情報ヘルパーを設定する

Windows のコマンドラインではなく Bash エミュレーターを使用している場合は、二重引用符ではなく単一引用符を使用する必要があります。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2