开发者社区> 问答> 正文

git push origin master 每次都要输入用户名和密码,怎么解决?:报错

D:\wamp\www\ypa>git push origin master
Username for 'https://github.com':

有什么方法可以保存用户名和密码的吗?

展开
收起
kun坤 2020-06-06 14:03:46 1832 0
1 条回答
写回答
取消 提交回答
  • 修改 gitconfig文件

    https://[userName]:[password]@github.com/[username]/project.git

    ######

    使用ssh key

    或者 

    https 方式使用git@osc设置密码的方式

    ######一般的IDE都有记住git用户名和密码的功能吧######

    引用来自“Zoker”的评论

    使用ssh key

    或者 

    https 方式使用git@osc设置密码的方式

    长期存储密码:

    git config --global credential.helper store

    保存了什么密码?store这个字符串。。。怎么长期保存密码。。。


    ######卧槽。加个密钥用ssh######ssh######不要用https,搞个公钥放到git服务器上不就行了######

    引用来自“jeffsui”的评论

    修改 gitconfig文件

    https://[userName]:[password]@github.com/[username]/project.git

    我用了这个命令了,现在后悔了,想回到这条命令之前的样子,就是取消这条命令,应该怎么办?
    因为用过这条命令之后,git push origin master 没反应了,就一个光标在跳,没有任何反应了。。。

    git config --global credential.helper store

    怎么去掉这个credential的配置? 

    D:\wamp\www\ypa>git config -l | grep "credential" credential.helper=store
    D:\wamp\www\ypa> 

    哦,我用unset去掉了 D:\wamp\www\ypa>git config --unset credential.helper


    但我还是不知道怎么修改gitcofig文件。。。

    ######

    引用来自“cups_book”的评论

    引用来自“jeffsui”的评论

    修改 gitconfig文件

    https://[userName]:[password]@github.com/[username]/project.git

    我用了这个命令了,现在后悔了,想回到这条命令之前的样子,就是取消这条命令,应该怎么办?
    因为用过这条命令之后,git push origin master 没反应了,就一个光标在跳,没有任何反应了。。。

    git config --global credential.helper store

    怎么去掉这个credential的配置? 

    D:\wamp\www\ypa>git config -l | grep "credential" credential.helper=store
    D:\wamp\www\ypa> 

    哦,我用unset去掉了 D:\wamp\www\ypa>git config --unset credential.helper


    但我还是不知道怎么修改gitcofig文件。。。

    不修改文件,可以通过命令行方式实现

    git remote -v //查看当前的远程仓库
    git remote rm origin //如果你的远程仓库别名叫origin的话,删除
    git remote add origin repo_url //添加远程仓库



    就可以了
    2020-06-08 11:23:34
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
新一代高效Git协同模型 立即下载
AGit-Flow:新一代高效Git协同模型 立即下载
AGit-flow:新一代高效Git协同模型 立即下载

相关实验场景

更多