fatal: could not read Username for 解决方案

fatal: could not read Username for 'http:// 解决方案

在部署drone(CICD软件)后,触发提交时,drone-runner执行拉取仓库代码(在自己部署的gogs上)时出现该问题

Initialized empty Git repository in /drone/src/.git/
+ git fetch origin +refs/heads/master:
fatal: could not read Username for 'http://ip:port': terminal prompts disabled

原因提示为需要输入用户名密码,但由于这是CICD软件,并没有输入密码的时机,因此解决方案有两种:

  • 使用 ssh,在drone所在服务器生产 git 公钥,上传到代码托管(我这里用的自己搭建的 gogs,实际上也会有github、gitea、gitee、gitlab等等),即可不需要用户名密码下载上传
  • 使用git的记忆密码机制保存用户名密码
    • 进入 drone 所在服务器,使用 drone 进程用户登录,进入家目录(cd ~
    • 执行 git clone [你的git代码路径] ,发现需要输入密码,ctrl + c 中断
    • 执行 touch .git-credentials 创建 .git-credentials 文件
    • 执行 vim .git-credentials 编辑该文件
    • 按 i 键进入编辑模式,输入:http(s)://{你的用户名}:{你的密码}@你的git服务器地址 【注意选择 https/http,去掉花括号】
    • ESC 输入 :wq 保存并退出
    • 执行 git config --global credential.helper store
    • cat ~/.gitconfig 发现多了一项:
      [credential]
      helper = store
      
    • 说明已经配置好了,再次 git clone [你的git代码路径] 试试,不需要输入密码了

fatal: could not read Username for ‘http://…’ : terminal prompts disabled 问题解决~

  • 7
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值