简体   繁体   English

无法将SourceTree连接到AWS CodeCommit

[英]Failed to connect SourceTree to AWS CodeCommit

I'm using Atlassian's SourceTree to work with git on Mac OS, and choose AWS CodeCommit as the remote hosting server. 我正在使用Atlassian的SourceTree在Mac OS上使用git,并选择AWS CodeCommit作为远程托管服务器。

Following these steps for HTTPs connection between AWS and my local repo, 按照以下步骤在AWS和我的本地存储库之间建立HTTP连接,

here's how my git config --global --edit looks like: 这是我的git config --global --edit样子:

在此输入图像描述

Then try to clone a created empty repo from AWS to SourceTree: 然后尝试将创建的空仓库从AWS克隆到SourceTree: 在此输入图像描述

And I get error printed out: 我打印出错误:

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 abort:HTTP错误403:禁止aws --profile默认codecommit credential-helper $ @ get:aws:command not found fatal:无法访问' https://git-codecommit.us-east-1.amazonaws.com/v1 / repos / my-git-repo / ':请求的URL返回错误:403

UPDATE UPDATE

Tried the answer provided by @Steffen Opel and got more like: 试过@Steffen欧宝提供的答案,更像是:

在此输入图像描述

Did I miss anything? 我错过了什么吗?

seems about right. 似乎是对的。 the "command not found" is the problem. “找不到命令”是问题所在。 I would say that aws is not in the path, and when the credential helper tries to help it cannot find it. 我会说aws不在路径中,当凭证助手试图帮助它找不到它。 double check it's in the path by doing which aws 通过做which aws仔细检查它在路径中

I have not tested this, but given AWS CodeCommit facilitates a credential helper too and the error being command 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'." 我没有对此进行测试,但鉴于AWS CodeCommit也促进了凭证帮助,并且command not found错误,我认为您受到SourceTree知识库文章中所述的相同问题的影响。 凭证帮助“git:'credential-osxkeychain'不是git命令。请参阅'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. 发生错误[...]是因为Git调用此帮助程序并且找不到它意味着它已经定义但在PATH上找不到。 In terms of SourceTree as of version 1.6.3 this is nothing to worry about. 就SourceTree而言,从版本1.6.3开始,这无需担心。 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. 不推荐,但是如果您只是将SourceTree用于所有内容,则可以从/ usr / local / git / etc / gitconfig配置中删除“凭证”设置。 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. 建议,在SourceTree应用程序资源中的git-credential-osxkeychain和本地git install之间创建一个符号链接。

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

Of course, since AWS CodeCommit requires the credential helper to be in place, only solution 2 is conceptually applicable for your scenario and you need to adjust the link source and targets as appropriate for the CodeCommit credential helper. 当然,由于AWS CodeCommit需要凭证帮助程序,因此只有解决方案2在概念上适用于您的方案,并且您需要根据CodeCommit凭证帮助程序调整链接源和目标。

I just found this answer here ( https://geekprotem.com/2015/07/10/aws-codecommit-with-sourcetree/ ) 我刚刚在这里找到了这个答案( https://geekprotem.com/2015/07/10/aws-codecommit-with-sourcetree/

After following the setup steps for AWS CLI on Amazon's website, the final step to get this to work was editing my repository's config file in SourceTree to include the following: 在亚马逊网站上执行AWS CLI的设置步骤之后,要使其工作的最后一步是在SourceTree中编辑我的存储库配置文件以包含以下内容:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM