美文网首页
git 命令行pull,push避免重复输入用户名密码

git 命令行pull,push避免重复输入用户名密码

作者: 微笑惊世骇俗 | 来源:发表于2018-03-05 23:39 被阅读0次

1、在git bash命令行中输入   echo $HOME  查看git home路径。

2、进入home对应的路径中。

touch .git-credentials    创建.git-credentials

vim .git-credentials 编辑

在./git-credentials中加入以下文本(此处文本URL可以固定写成这样,如果你的URL和这个不一样,执行完以下操作之后只需要在命令行输入一次

用户名密码会自动把你所使用的URL追加进去),username 和password分别代表用户名密码

https://username:password@github.com

git config --global credential.helper store

这是查看home路径中的.gitconfig,会在之前

[user]

name =

**********

email=***********

的基础上多出

[credential]

helper = stor

e

3、在命令行正常执行pull ,push,如果是在以上操作完之后第一次执行向任何URL的pull push,需要输入一次用户名密码,以后不再需要输入。

第一次向新的URL输入用户名密码之后会发现 .git-credentials中追加了类似https://username:password@hello.com的内容。

相关文章

网友评论

      本文标题:git 命令行pull,push避免重复输入用户名密码

      本文链接:https://www.haomeiwen.com/subject/vdwkfftx.html