---
title: "Git学习之Windows下的安装与基本设置"
author: "haifengyulu"
date: "2012-11-11T22:49:44Z"
tags: []
categories: ["开源软件"]
slug: "git-windows"
draft: false
lastmod: "2012-11-11T22:52:03Z"
id: 1722608
url: "https://seazenith.iteye.com/blog/1722608"
---

最近因为项目的需要，在学习使用DVCS——Git

在windows环境下使用git管理项目，可以使用Google Code上的"Git on MSys"项目

下载地址是：[http://coge.google.com/p/msysgi](http://code.google.com/p/msysgit/)t

一般按照默认设置进行安装即可，安装完成之后，可以使用git --version来检验安装成功与否

配置：

 

git提供了config工具来配置以下三份git配置文件：

- /etc/gitconfig: git的系统全局配置文件，该配置文件中的配置选项对操作系统上所有使用git的用户产生影响，使用git config –system可以针对此文件进行配置；
- ~/.gitconfig: git的用户全局配置文件，该配置文件的配置选项对当前用户产生影响，并且会覆盖掉系统全局配置文件中已经存在的配置选项，使用git config –global可以针对此文件进行配置；
- .git/config: 该文件存在每个git镜像下，其配置文件的配置选项仅对该git镜像产生影响，它会覆盖掉用户全局配置文件中已经存在的配置选项。

了解了配置git的文件位置与机制后，我们首先就来尝试配置一下git的用户信息：

 

```
$ git config --global user.name "zhangsan"
$ git config --global user.email zhangsan@gmail.com
```

可以使用如下命令来查看当前的设置是否成功：

```
$ git config --global --list
```

除了用户信息外，通常还可以开启在命令行窗口中用不同的颜色显示不同类型的内容，以及设置默认的提交留言等的编辑器(如果不设置，默认启动vim编辑器)

 

```
$ git config --global color.ui auto
$ git config --global core.editor notepad++.exe
```

 此外，还可以设置常用命令的别名，如

 

```
$ git config --global alias.st status
$ git config --global alias.ci commit
$ git config --global alias.co checkout
```