- Git学习开始,虽然只是工具。
文章目录
- 1 Git安装
- 2 检查Git安装版本
- 3 Git的最小配置
- 4 git config的其它作用域
- 5 总结
1 Git安装
- 下面是安装Git的的官网链接:
Git安装
- 分别有Linux安装、Mac安装与Windows安装的方法。我个人安装Windows与Linux。方法在上面链接中打开都可以看到对应的,很简单,这里就不再写了。
2 检查Git安装版本
打开Git:
- Linux下直接输入git命令即可使用Git。Windows下直接打开软件即可进入Git命令行使用Git
在Git的命令行执行以下命令,将会返回git的版本。
- git --version
Windows下显示:git version 2.20.1.windows.1
Linux下显示:git version 2.17.1
3 Git的最小配置
在使用git前需要对git做最小配置。也就是需要配置user.name和user.email
如果不做最小配置,git是无法使用的。
$ git config --global user.name ‘your_name’ $ git config --global user.email ‘your_email@domain.com’
- 上述的global表示对登录用户的所有仓库有效
- your_name可以设置为自己喜欢的名字
- your_email@domain.com可以设置为自己的邮箱
为了方便以后,最小配置做完后,建议再设置一下local的name和email。最好不要与global的一样
4 git config的其它作用域
上面是配置的global域,config还有其他作用域:
$ git config --local local只对仓库有效。此也为缺省条件下的配置
$ git config --global global对登录用户的所有仓库都有效
$ git config --system system对系统的所有用户都有效
当你设置好config的配置后,如果想查看配置信息,加 --list
即可。如下:
$ git config --list --local
$ git config --list --global
$ git config --list --system
如果想清楚config配置,使用 --unset
。如下:
$ git config --unset --local user.name
$ git config --unset --global user.name
$ git config --unset --system user.name
上面三个作用域是由一定的优先级的:local > global > system
5 总结
-
学会Git的最小配置
git config [–local | --global | --system] user.name ‘Your name’
git config [–local | --global | --system] user.email ‘Your email’ -
查看配置
git config --list [–local | --global | --system]
学习交流加
- 个人qq:
1126137994- 个人微信:
liu1126137994- 学习交流资源分享qq群:
962535112