首页 > 解决方案 > Bash/Git - 提示用户输入密码

问题描述

我制作了一个 bash 脚本,可以自动将 git 提交到远程。但是,当它到达提交时,它不会将 SSH 密钥密码提示传递给用户,它只是退出。

这是脚本的相关部分!

set -e

[...]

read -p "Would you like to upload your app now? [y/n]: " -n 1 -r
echo    # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
    exit 1
fi

git add *
git commit -m "Commit (Automated)"
git push cloud master

不是真正的 shell 脚本人,所以任何帮助将不胜感激!

编辑:澄清我希望提示用户在“git push ...”中输入密码

标签: bashgit

解决方案


解决了!看起来我脚本顶部的“set -e”是罪魁祸首。它将 git commit 命令“一切都是最新的”响应视为命令失败并退出。删除它解决了问题:D


推荐阅读