• git 记住用户名和密码


    git 记住用户名和密码

    在使用 git 时,如果用的是 HTTPS 的方式,则每次提交,都会让输入用户名和密码,久而久之,就会感觉非常麻烦,那么该如何解决呢?

    1. 使用 SSH,添加 ssh key。

    2. 在全局中存储用户的账号密码,方式如下

    第一步:在 %HOME% 目录中,创建 .git-credentials 文件

    一般为 C:usersAdministrator,也可以是你自己创建的系统用户名目录,反正都在 C:users*** 中。

    Windows 中创建以 . 开头的文件的方法:

    1. 新建 test.txt 记事本,然后另存为 .git-credentials

    2. 使用 git bash

       touch .git-credentials
      

    创建完成后,在该文件中输入:

    https://username:password@github.com
    

    注:username 对应你的用户名,password 对应你的密码

    第二步:再进入 git bash 中

    git config --global credential.helper store
    

    store 为永久存储,当然也可以设置临时的

    # 临时存储,默认为15分钟
    git config –global credential.helper cache
    # 设置保存时间
    git config credential.helper 'cache –timeout=3600'
    

    执行完后查看 %HOME% 目录下的 .gitconfig 文件,会多了一项:

    [credential]helper=store
    

    重新开启 git bash 会发现 git push 时不用再输入用户名和密码

    3. 单独对某个项目免密

    如果还未添加远程地址,可以输入一下命令:

    git remote add origin https://username:password@git.oschina.net/diligentyang/ysy107lab.git 
    

    如果已添加远程地址,最为简单的方式就是,直接在 .git/config 文件中进行修改,按如上格式,添加用户名和密码

    git config --list
    git config --global user.name "输入你的用户名"
    git config --global user.email "binarylei@qq.com"


    每天用心记录一点点。内容也许不重要,但习惯很重要!

  • 相关阅读:
    jmeter性能测试
    Robotframework 之常用断言关键字
    chrome浏览器的调试器乱码问题
    YDKJS:作用域与闭包
    JavaScript事件循环(Event Loop)机制
    第一次react-native项目实践要点总结
    jsonp 演示实例 —— 基于node
    Jquery属性获取——attr()与prop()
    实现跨域的N种方法
    了解闭包
  • 原文地址:https://www.cnblogs.com/binarylei/p/8680754.html
Copyright © 2020-2023  润新知