简体   繁体   English

在 AWS Code Commit 中使用用户名和密码进行 Git 拉取/克隆

[英]Git pull/clone with username and password in AWS Code Commit

I Need to do a git pull using https url as a oneline command .我需要使用 https url 作为单行命令执行 git pull 。 this command I need to integrate in a bash script .我需要将此命令集成到 bash 脚本中。 But all the time it is asking the usernmae and password .但它一直在询问用户名和密码。

The repository is in AWS codecommit存储库位于AWS 代码提交中

Check this link: Enter user password in command检查此链接: 在命令中输入用户密码

As is described perfectly in that post, you basically have three options:正如那篇文章中完美描述的那样,您基本上有三个选择:

  1. Store the password in .netrc file (with 600 permissions).将密码存储在 .netrc 文件中(具有 600 权限)。 Make sure you clone the repo specifying the username in the url.确保您克隆了在 url 中指定用户名的 repo。
  2. Clone the repo with https://user:pass@domain/repo .使用https://user:pass@domain/repo克隆https://user:pass@domain/repo Take into account that your password will be visible in several places...考虑到您的密码将在多个位置可见...
  3. Use the credential helper .使用凭证助手

Try this:试试这个:

git clone https://username:password@git-codecommit.us-east-1.amazonaws.com/v1../repos../..

This way worked for me for CodeCommit ( AWS ) repository这种方式对我适用于CodeCommit ( AWS ) 存储库

As an update, AWS has released their remote git remote codecommit.作为更新,AWS 发布了他们的远程 git 远程代码提交。 With proper IAM setup, you can do oneline pulls without even passing username and passwords.通过正确的 IAM 设置,您甚至可以在不传递用户名和密码的情况下进行单线拉取。 This is now the recommended method by AWS.这是 AWS 现在推荐的方法。 It can be setup on your local or on a container that's running in an AWS Pipeline for example.例如,它可以设置在您的本地或运行在 AWS Pipeline 中的容器上。

ie git clone codecommit://HelloWorldRepo myLocalHelloWorldRepo And then you can git pull as normal.git clone codecommit://HelloWorldRepo myLocalHelloWorldRepo然后你就可以正常git pull了。

Full documentation is here: https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-git-remote-codecommit.html完整文档在这里: https : //docs.aws.amazon.com/codecommit/latest/userguide/setting-up-git-remote-codecommit.html

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

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