我想从 Bash 脚本提供密码。我尝试了以下方法:
echo 'mypass' | git pull
git pull < 'mypass'
git pull < echo 'mypass'
似乎都不起作用。
最佳答案
创建文件
git_password.sh
内容:#!/bin/sh exec echo "$GIT_PASSWORD"
将您的密码分配给 GIT_PASSWORD 环境变量
$ GIT_PASSWORD=your_password
使用 GIT_ASKPASS 环境变量执行 git 命令。它将强制提示密码并执行 git_password.sh 作为回调:
$ GIT_ASKPASS=./git_password.sh git clone $REPO
关于git - 在 Bash 脚本中为 Git 提供密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31218599/