记住用户名密码
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 问题解决~
目前有 0 条留言 其中:访客:0 条, 博主:0 条