MAC/Linux 下 Git 记住用户名密码

Mac自带git,因此无需安装,可用如下命令查看git版本及安装位置linux

查看git位置
which git
whereis git

查看git版本

git --version

使用git前需先配置gitgit

git config --global user.name "Your Name"
git config --global user.email you@example.co

1.mac/linux下github

在~/下, touch建立文件 .git-credentials:
touch .git-credentials

# 用vim编辑此文件,
vim .git-credentials

#输入内容格式
https://username:password@github.com

2. 在终端下执行  vim

git config --global credential.helper store

 

 

能够看到~/.gitconfig文件,会多了一项:
[credential]
    helper = store

删除保存的密码:windows

一、删除保存的密码.net

git credential-osxkeychain erase

or:

printf "protocol=https\nhost=github.com\n" | git credential-osxkeychain erase

二、删除密码文件code

rm ~/.git-credentials

备注: git更改提交用户名报错对象

  • 缘由有两个:blog

    1. 没有擦除mac自身记忆的密码串
    2. 提交对象弄错。把提交地址写错,应该是git方式,误写成htts方式了。
  • Git修改提交user和email方法:get

    1. 使用指令修改: 
      git config –global user.name “name” –name是修改后的名字,去掉双引号 
      git config –global user.email “email” –email是修改后的邮箱地址,去掉双引号
    2. 修改配置文件。 
      在用户目录下:/home/username/,修改.gitconfig文件中对应的用户名和密码。
  • mac中擦除密钥串的方法: 
    使用指令:git credential-osxkeychain erase

更多:

windows下: http://www.javashuo.com/article/p-kytvemfg-hv.html

相关文章
相关标签/搜索