zoukankan      html  css  js  c++  java
  • git配置config记住密码

    设置记住密码(默认15分钟):

    git config --global credential.helper cache
    如果想自己设置时间,可以这样做:

    git config credential.helper 'cache --timeout=3600'
    这样就设置一个小时之后失效

    长期存储密码:

    git config --global credential.helper store
    增加远程地址的时候带上密码也是可以的。(推荐)

    从仓库的config的里面修改url,后面加上密码

    http://yourname:password@git.oschina.net/name/project.git
    补充:使用客户端也可以存储密码的。

    git设置用户名密码

    设置git用户名/邮箱

    git config --global user.name [username]
    git config --global user.email [email]

    但是这个仅仅是设置用户名密码,如果你的git 源每次操作需要你输入用户名/密码验证,你依然需要每次设置,那么该如何办呢?

    git保存用户名密码

    这里主要是配置一个config项

    有两个方法,基本上原理都是一样,都是修改.git/config文件

    1.使用如下命令,修改config文件即可保存

    echo "[credential]" >> .git/config
    echo "    helper = store" >> .git/config

    2.直接修改.git/config文件

    在linux/mac下可以直接使用vim工具修改config文件

    ubuntu@VM-7-212-ubuntu:~/kernel-code/kernel-netfilter-sample-code$ vim .git/config
    
    ##修改成如下
    
    [core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
    [remote "origin"]
        url = https://github.com/Miss-you/kernel-netfilter-sample-code.git
        fetch = +refs/heads/*:refs/remotes/origin/*
    [branch "master"]
        remote = origin
        merge = refs/heads/master
    ##主要是后面这两行,如果不想保存,则删除即可
    [credential]
        helper = store
    
    ##保存

    这样就可以保存用户名密码,不用每次都输入了!

    git config查看配置

    使用git config --list查看已设配置

    feiqianyousadeMacBook-Pro:xt_GTPU yousa$ git config --list
    core.excludesfile=/Users/yousa/.gitignore_global
    user.name=Miss-you
    user.email=snowfly1993@gmail.com
    core.repositoryformatversion=0
    core.filemode=true
    core.bare=false
    core.logallrefupdates=true
    core.ignorecase=true
    core.precomposeunicode=true
    remote.origin.url=https://github.com/Miss-you/xt_GTPU.git
    remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
    branch.master.remote=origin
    branch.master.merge=refs/heads/master
  • 相关阅读:
    即使年龄小,我也是你的领导
    当老外骂你时,你就这样...
    纵横职场宝典
    22岁女老总欲筹办创业联盟
    让你的发言语出惊人
    爱因斯坦难题,98%的人答不出这道题!
    小本创业的11个步骤
    未来十大热门挣钱职业
    常用英语对话
    折腾是检验人才的唯一标准
  • 原文地址:https://www.cnblogs.com/marblemm/p/7993194.html
Copyright © 2011-2022 走看看