git bash终端(命令行)输入密码而不使用对话框输入密码
前言全局说明
在 Windows 上,输入密码时会弹出对话框,输入还要用鼠标点击,很部方便,下面是设置如何在终端(命令行)输入密码。
一、说明
1.1 环境:
Windows 10 22H2
Git-2.50.1-64-bit.exe (文末下载链接)
二、说明
当没有任何的证书小助手(credential helpers)定义的时候,Git将会按照如下的策略检查,并请求用户输入用户名和密码
1. GIT_ASKPASS环境变量
2. core.askPass配置
3. SSH_ASKPASS配置
4. 终端命令行输入
前3个都是由专门程序管理,最后才是让命令行输入,那么就要将前三个设置为失效(不启用)
三、查看
在 git bash 里执行下面命令
3.1 查看所有配置
git config --list --show-origin
3.2 查看 helper 配置
git config --list --show-origin | grep helper
或
git config --list --system | grep helper
或
git config --list --global | grep helper
3.3 查看 askpass 配置
git config --list --show-origin | grep "*askpass*"
或
git config --list --system | grep "*askpass*"
或
git config --list --global | grep "*askpass*"
四、取消 credential.helper 设置
删除 system credential.helper 设置
4.1 方式一:取消命令
git config --system --unset credential.helper
和
git config --global --unset credential.helper
4.2 方式二:vim 编辑命令
手动编辑,删除 [credential]下的 helper=xxx
git config --edit --system
和
git config --edit --global
默认编辑器是 vim (不会操作可以网上搜一下,建议使用上面3.2.1命令操作)
不想删除可以用 shell注释符号# 。
示例:helper --> #helper
五、取消 askpass 程序路径
禁用OpenSSH凭据弹出窗口
5.1 方式一:取消命令
git config --system core.askpass ""
和
git config --global core.askpass ""
5.2 方式二:vim 编辑命令
git config --edit --system
和
git config --edit --global
增加下面内容:
[core]
askpass =
六、--system 和 --global 更详细介绍
https://www.cnblogs.com/wutou/p/17585668.html
七、用户名设置
clone 一个仓库后只有仓库链接,没有用户名,可以手动指定。
git remote set-url origin https://你想要写的用户名@gitee.com/test/test
origin 是你执行 git remote -v 时看到左边第一列名字,
根据 origin 确定你要修改哪个链接
如果一个本地仓库,指向多个远程仓库,那 origin 名是不一样的,比如 origin_1
下图,修改前:

下图,修改后:

八、Git-2.50.1-64-bit.exe 下载
免责声明:本号所涉及内容仅供安全研究与教学使用,如出现其他风险,后果自负。
参考、来源:
https://blog.csdn.net/lovedingd/article/details/120165624
https://cn.bing.com/search?q=禁用GIT ASKPASS环境变量&qs=n&form=QBRE&sp=-1&lq=0&pq=禁用git askpass环境变量&sc=0-17&sk=&cvid=2BA481A685AD4F3585D226FFD3E6B1E7&ntref=1
https://dev59.com/Z1oU5IYBdhLWcg3wu4ji
https://www.oryoy.com/news/zhang-wo-git-qing-song-xiu-gai-config-pei-zhi-mi-ma-gao-bie-shou-dong-shu-ru-mi-ma-fan-nao-a14763698.html#:~:text=本文将详细指导你如何轻松修改Git的config配置文件中的密码,让你告别手动输入密码的烦恼。 1. 打开Git配置文件 首先,你需要打开Git的配置文件。 在命令行中输入以下命令: 这条命令会列出所有的Git配置项。 找到其中的,user.password 配置项,它包含了你的密码。 2. 修改密码 要修改密码,你可以使用 git config 命令。 (禁用密码认证)
浙公网安备 33010602011771号