无法将 SourceTree 连接到 AWS CodeCommit

Failed to connect SourceTree to AWS CodeCommit

我在 Mac OS 上使用 Atlassian 的 SourceTree 与 git 一起工作,并选择 AWS CodeCommit 作为远程托管服务器。

遵循这些 steps 用于 AWS 和我的本地存储库之间的 HTTPS 连接,

这是我的 git config --global --edit 的样子:

然后尝试将创建的空存储库从 AWS 克隆到 SourceTree:

然后我打印出错误:

abort: HTTP Error 403: Forbidden aws --profile default codecommit credential-helper $@ get: aws: command not found fatal: unable to access 'https://git-codecommit.us-east-1.amazonaws.com/v1/repos/my-git-repo/': The requested URL returned error: 403

更新

尝试了@Steffen Opel 提供的答案,得到的答案更像:

我错过了什么吗?

似乎是对的。 "command not found" 是问题所在。 我会说 aws 不在路径中,当凭证助手试图帮助它时找不到它。通过 which aws

仔细检查它在路径中

我还没有对此进行测试,但考虑到 AWS CodeCommit 有助于 credential helper too and the error beingcommand not found, I would assume you are affected by the same issue outlined in the SourceTree Knowledge Base article Credential helpers "git: 'credential-osxkeychain' is not a git command. See 'git --help'.":

The error [...] occurs because Git calls this helper and cannot find it meaning it has been defined and yet not found on the PATH. In terms of SourceTree as of version 1.6.3 this is nothing to worry about. There's two ways to stop this from happening.

  1. Not recommended, but if you're solely using SourceTree for everything you could remove the 'credential' setting from the /usr/local/git/etc/gitconfig config. This is a quick and easy method, but it does mean operations at the terminal may not be able to authenticate.
  2. Recommended, create a symlink between git-credential-osxkeychain in the SourceTree app resources and your local git install.

    ln -s /usr/local/git/bin/git-credential-osxkeychain /Applications/SourceTree.app/Contents/Resources/git_local/bin/git-credential-osxkeychain

当然,由于 AWS CodeCommit 需要凭证助手,只有解决方案 2 在概念上适用于您的场景,您需要根据 CodeCommit 凭证助手调整 link 源和目标.

我刚在这里找到这个答案 (https://geekprotem.com/2015/07/10/aws-codecommit-with-sourcetree/)

按照 Amazon 网站上的 AWS CLI 设置步骤进行操作后,要使其正常工作的最后一步是在 SourceTree 中编辑我存储库的配置文件以包括以下内容:

[credential]
helper = /usr/local/bin/aws codecommit credential-helper $@
UseHttpPath = true