linux系统下每次git pull输入用户名密码
方式一 git配置在用户家目录~生成.git-credentialsusername和password换成你自己的echo "https://{username}:{password}@github.com" > .git-credentials添加到git 全局配置git config --global credential.helper store查看git配置g...
·
linux系统下每次git pull
git push
都需要输入用户名密码
方式一 git配置
-
在用户家目录
~
生成.git-credentials
username和password换成你自己的
echo "https://{username}:{password}@github.com" > .git-credentials
-
添加到git 全局配置
git config --global credential.helper store
-
查看git配置
git config --list
输出内容包含credential.helper=store
,就OK了
方式二:expect实现shell 脚本自动输入账号密码
前提:系统中需要安装`expect`,脚本都有可执行权限
更新代码脚本update.sh
cd /www/wwwroot/font
git pull origin master
执行脚本过程中,模拟手输用户名、密码 的脚本expect_pull.sh
#!/usr/bin/expect -f
spawn ./update.sh # 在expect下执行update.sh
expect "Username for 'https://gitee.com'" #expect监视终端 输出双引号中的文字
send -- "你的gitee用户名\n" # 向终端发送指定信息 # 双横线后面有一个空格
expect "Password for 'https://你的gitee用户名@gitee.com'"
send -- "你的gitee密码\n"
interact # 保持交互,不要退出。没有这句的话,完成后会自动退出。
更多推荐
已为社区贡献1条内容
所有评论(0)