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

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐