安装git
发布者:admin 发表于:442天前 阅读数:613 评论:0

前言

git是全版本的软件,下载安装时请选择对应的系统即可

在Windows上安装

前往官网下载对应客户端:https://git-scm.com/downloads

下载完成后默认安装即可,(默认会将git添加到系统环境变量)

在Mac上安装

如果你正在使用Mac做开发,有两种安装Git的方法。

一是安装homebrew,然后通过homebrew安装Git,具体方法请参考homebrew文档:https://brew.sh/index_zh-cn

第二种方法更简单,也是推荐的方法,就是直接从AppStore安装XcodeXcode集成了Git,不过默认没有安装,你需要运行Xcode,选择菜单Xcode->Preferences,在弹出窗口中找到Downloads,选择Command Line Tools,点Install就可以完成安装了。

在Linux上安装

首先,试着在终端里面输入git,查看是否已安装,若出现下列内容,则说明没有安装git

$ git
The program 'git' is currently not installed. You can install it by typing:
sudo apt-get install git

所以,Ubuntu系统使用:

sudo apt-get install git

CentOS使用:

sudo yum install git -y

其他版本Linux需要使用源码编译安装

先去官网下载最新版本压缩包:https://github.com/git/git/releases

解压之后执行下列命令:

git clone https://github.com/git/git.git
./configure
make
sudo make install

配置

安装好git之后,需要配置一下才可以正常使用,打开命令行,执行:

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

上述命令里的name和Email是你注册GitHub时使用的name和Email

注意git config命令的–global参数,用了这个参数,表示你这台机器上所有的Git仓库都会使用这个配置,当然也可以对某个仓库指定不同的用户名和Email地址。