创建存储用户名密码的文件

在home文件夹,一般是 C:\Documents and Settings\Administrator 下建立文件 .git-credentials (windows下不允许直接创建以.开头的文件,所以有一个小技巧:先创建一个文件名叫 )git-credentials 然后进入 git bash 使用命令:

mv git-credentials .git-credentials

用记事本打开这文件输入:

https://{username}:{password}@github.com

比如:

https://zhangsan:123456@github.com

保存

添加config项

在任意文件夹下右键进入 git bash

然后输入:

git config --global credential.helper store

执行完后去查看 C:\Documents and Settings\Administrator\.gitconfig 这个文件,发现多了一项:

[credential]
helper = store

就成功了。

然后要重开 git bash 窗口,再提交就不用输入用户名密码

参考资料:

git-credential-cache(1) Manual Page

NAME

git-credential-cache - helper to temporarily store passwords in memory

SYNOPSIS

git config credential.helper 'cache [options]'

DESCRIPTION

This command caches credentials in memory for use by future git programs. The stored credentials never touch the disk, and are forgotten after a configurable timeout. The cache is accessible over a Unix domain socket, restricted to the current user by filesystem permissions.

You probably don’t want to invoke this command directly; it is meant to be used as a credential helper by other parts of git. Seegitcredentials(7) or EXAMPLES below.

OPTIONS

--timeout <seconds>

Number of seconds to cache credentials (default: 900).

--socket <path>

Use <path> to contact a running cache daemon (or start a new cache daemon if one is not started). Defaults to ~/.git-credential-cache/socket. If your home directory is on a network-mounted filesystem, you may need to change this to a local filesystem.

CONTROLLING THE DAEMON

If you would like the daemon to exit early, forgetting all cached credentials before their timeout, you can issue an exit action:

git credential-cache exit

EXAMPLES

The point of this helper is to reduce the number of times you must type your username or password. For example:

$ git config credential.helper cache
$ git push http://example.com/repo.git
Username: <type your username>
Password: <type your password> [work for 5 more minutes]
$ git push http://example.com/repo.git
[your credentials are used automatically]

You can provide options via the credential.helper configuration variable (this example drops the cache time to 5 minutes):

$ git config credential.helper 'cache --timeout=300'

git for windows (又名 msysgit)如何记住用户名和密码的更多相关文章

  1. git 记住用户名和密码

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

  2. Tortoisegit 记住用户名和密码

    Tortoisegit 记住用户名和密码方法: [Windows系统] 当你配置好git后,在 C:\Documents and Settings\Administrator\ 目录下有一个  .gi ...

  3. TortoiseGit:记住用户名和密码

    1.背景: 我们在使用 tortoisegit 工具时会无可避免的经常性 pull 和 push,这时通常要输入用户名和密码,由于麻烦,就有人提出了记住用户名和密码的需求... ... 2.设置: [ ...

  4. OpenVPN 如何记住用户名和密码

    最近在使用OpenVPN,但是没有记住用户名和密码功能,太坑人,研究一下发现是可以的. 1. 在OpenVPN安装目录下\OpenVPN\config文件夹中找到vpnserver.ovpn文件. 2 ...

  5. ASP.NET中登录时记住用户名和密码(附源码下载)--ASP.NET

    必需了解的:实例需要做的是Cookie对象的创建和对Cookie对象数据的读取,通过Response对象的Cookies属性创建Cookie,通过Request对象的Cookies可以读取Cookie ...

  6. 通过jquery.cookie.js实现记住用户名、密码登录功能

    Cookies 定义:让网站服务器把少量数据储存到客户端的硬盘或内存,从客户端的硬盘读取数据的一种技术: 下载与引入:jquery.cookie.js基于jquery:先引入jquery,再引入:jq ...

  7. jQuery cookie 实现记住用户名和密码功能

    jQuery cookie 实现记住用户名和密码功能 HTML代码 <div class="wrap"> <div class="line-top&qu ...

  8. SVN记住用户名和密码后如何修改

    今天遇到一个SVN检出代码用户验证问题.由于自己最近参与了好几个项目,一时间忙不过来.所以希望跟着自己的试用期的同事帮我测试一下刚修改完成的新功能是否有问题.但是该同事没有项目中权限,正好今天恰逢星期 ...

  9. (转)ASP.NET里面简单的记住用户名和密码

    using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Web; 5 using S ...

  10. jquery实现记住用户名和密码

    这里我们选择的方法是cookie的方式去记录 首先我们写将用户名和密码写到cookie的js代码 //保存到cookie function save_cookies(){ if($("#re ...

随机推荐

  1. 三个API:开启、关闭、关闭线程重定向

    C:\Windows\sysnative\ 这个目录是作什么用的?来源:互联网 责任编辑:小易 时间:2015/11/13 0:17:19用户提出问题:C:\Windows\sysnative\ 这个 ...

  2. MvvmLight Messenger(信使)

    MvvmLight信使需要三个部分: 1.自定义信件类,普通的Model,供在发布者和订阅者之间传递信息用. 2.发布,通常是在某一事件函数中进行发布,Messenger.Default.Send 3 ...

  3. 在不同编译环境中如何使用sleep()函数

    今天在学习有关时间函数时,想让程序暂时挂起,一段时间后在继续执行! 用到了系统函数sleep(): 在vc下sleep函数是以毫秒为单位,如果想让其停留3秒,需要这样做  sleep(3*1000); ...

  4. [转]Cocos Studio和Cocos2d-x版本对应关系

    2015-1-19阅读139 评论0 From: http://www.cocoachina.com/bbs/read.php?tid=182077 版本对应列表: Studio2.x CocosSt ...

  5. SSH2三大框架整合警告

    *********************************************************************** * WARNING!!! * * * * >> ...

  6. Android 点亮屏幕

    前言          欢迎大家我分享和推荐好用的代码段~~ 声明          欢迎转载,但请保留文章原始出处:          CSDN:http://www.csdn.net        ...

  7. 基于visual Studio2013解决面试题之1101差值最小

     题目

  8. 基于visual Studio2013解决C语言竞赛题之1021九九乘法表

         题目 解决代码及点评 /* 功能:请编程序按如下格式打印一个直角三角形的九九乘法表: 1 2 3 4 5 6 7 8 9 4 6 8 10 12 14 16 18 9 1 ...

  9. Mockito文档-单元测试技术

    Overview  Package   Class  Use  Tree  Deprecated  Index  Help     PREV CLASS   NEXT CLASS FRAMES     ...

  10. 手机端viewport的设置规范

    <meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0, maximum-scale ...