Mac自带git,所以无需安装,可用以下命令查看git版本及安装位置
查看git位置
which git
whereis git
查看git版本
git --version
使用git前需先配置git
git config --global user.name "Your Name"
git config --global user.email you@example.co
1.mac/linux下
在~/下, touch创建文件 .git-credentials:
touch .git-credentials
# 用vim编辑此文件,
vim .git-credentials
#输入内容格式
https://username:password@github.com
2. 在终端下执行
git config --global credential.helper store
可以看到~/.gitconfig文件,会多了一项:
[credential]
helper = store
删除保存的密码:
1、删除保存的密码
git credential-osxkeychain erase
or:
printf "protocol=https\nhost=github.com\n" | git credential-osxkeychain erase
2、删除密码文件
rm ~/.git-credentials
备注: git更改提交用户名报错
原因有两个:
没有擦除mac自身记忆的密码串
提交对象弄错。把提交地址写错,应该是git方式,误写成htts方式了。
Git修改提交user和email方法:
使用指令修改:
git config –global user.name “name” –name是修改后的名字,去掉双引号
git config –global user.email “email” –email是修改后的邮箱地址,去掉双引号
修改配置文件。
在用户目录下:/home/username/,修改.gitconfig文件中对应的用户名和密码。
mac中擦除密钥串的方法:
使用指令:git credential-osxkeychain erase
更多:
来源:oschina
链接:https://my.oschina.net/u/2399426/blog/803036