先清理坏掉的键(可能不存在,报错可忽略)
git config --global --unset-all credential.usehttppath 2>/dev/null || true
git config --global --unset-all credential.UseHttpPath 2>/dev/null || true
正确设置 CodeCommit 的认证助手
git config --global credential.helper '!aws codecommit credential-helper $@'
注意大小写:UseHttpPath(H 和 P 大写)
git config --global credential.UseHttpPath true
可选:设置提交者信息(只影响 commit 作者,不影响认证)
git config --global user.name "lihao"
git config --global user.email "ri.kou.02@adniss.jp"
检查结果
git config --global -l
aws sts get-caller-identity # 确认 CloudShell 的 IAM 身份正常