git config

git config命令用来设置git的一些配置(包括全局配置和针对单个仓储的配置).git config命令能定义一个仓储的用户信息和用户偏好.

用法

git config user.name <name>

为当前仓储的commit定义作者的名字. 通常我们在这会使用--global这样所有以后的本地的其他的仓储的commit的作者名都设置统一了(--global意味着这是一个全局配置).

git config --global user.name <name>

为当前机器上当前用户的以后所有的仓储的所有commit定义了作者名.

git config --global user.email <email>

为当前机器上当前用户的以后所有的仓储的所有commit定义了作者的邮箱.  

git config --global alias.<alias-name> <git-command>

定义git命令的简写.

git config --system core.editor <editor>

定义命令(如commit命令)的文本编辑器 --system代表时系统级别的配置作用于这台电脑上的所有用户.

git config --global --edit

用文本编辑器打开当前机器上当前用户的配置文件手工进行修改.

讨论

所有的配置选项都存储在纯文本文件中, git config命令只不是一种方便的命令行接口. 通常情况下, 在一台全新的机器一到手我们会先使用--global来进行一些全局设置, 然后再开始工作.

Git把配置文件存储在三个不同的文件中, 一个作用于独立仓储, 一个作用于当前用户, 一个作用于整个系统:

  • <repo>/.git/config  - 这个是当前仓储的配置
  • ~/.gitconfig  - 用户所属的配置. 用--global的配置存放在这
  • $(prefix)/etc/gitconfig  - 系统级别的配置

当这3个文件相冲突的时候. 当前仓储的配置覆盖用户所属的配置, 用户所属的配置覆盖系统级别的配置. 打开一个配置文件, 你会看到如下内容:

[user]
name = John Smith
email = john@example.com
[alias]
st = status
co = checkout
br = branch
up = rebase
ci = commit
[core]
editor = vim

你可以在这个文本中直接修改配置, 效果和git config一样.

例子

安装完Git后第一件事就是设置name/email. 一个典型的设置如下:

# 告诉Git你是谁
git config --global user.name "John Smith"
git config --global user.email john@example.com

  

# 设置你喜欢的文本编辑器
git config --global core.editor vim
# 添加一些git命令的别名
git config --global alias.st status
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.up rebase
git config --global alias.ci commit

  

[译]git config的更多相关文章

  1. git config 配置

    1. git config简介 我们知道config是配置的意思,那么git config命令就是对git进行一些配置.而配置一般都是写在配置文件里面,那么git的配置文件在哪里呢?互动一下,先问下大 ...

  2. 学习git config配置文件

    设置 git status的颜色. git config --global color.status auto 一.Git已经在你的系统中了,你会做一些事情来客户化你的Git环境.你只需要做这些设置一 ...

  3. git config命令使用

    1. git config简介 我们知道config是配置的意思,那么git config命令就是对git进行一些配置.而配置一般都是写在配置文件里面,那么git的配置文件在哪里呢?互动一下,先问下大 ...

  4. git config --global core.autocrlf false

    git config --global core.autocrlf  false warning: LF will be replaced by CRLF in .idea/vcs.xml.The f ...

  5. [译]git pull

    git pull把git fetch和git merge压缩成了一条命令. 用法 git pull <remote> 作用和git fetch <remote> &&a ...

  6. git config proxy

    $ export http_proxy=http://proxy.ip.ad.ress:portnumber/ $ export https_proxy=http://proxy.ip.ad.ress ...

  7. [git]解决:git config --global push.default matching

    解决:git config --global push.default matching 这个警告的意思是:需要设置默认push的分支,所以设置好全局push的默认分支就好了.命令如下: 在有git目 ...

  8. git config配置文件

    设置 git status的颜色. git config --global color.status auto 一.Git已经在你的系统中了,你会做一些事情来客户化你的Git环境.你只需要做这些设置一 ...

  9. git config(转载)

    From:http://www.g2w.me/2013/10/cache-github-credential-for-https-repository/ http://openwares.net/li ...

随机推荐

  1. Linux修改密码passwd用法

    语法: passwd [-k] [-l] [-u [-f]] [-d] [-S] [username] 必要参数:-d 删除密码-f 强制执行-k 更新只能发送在过期之后-l 停止账号使用-S 显示密 ...

  2. 微信公众平台教程和SDK收集

    教程收集: 1.Senparc(.net) http://www.cnblogs.com/szw/archive/2013/05/14/weixin-course-index.html 2.方倍工作室 ...

  3. Android数据存储-通过SharedPreferences实现记住密码的操作

    在Android中登陆中,为了实现用户的方便,往往需要根据用户的需要进行记住密码的操作,所以,在Android数据存储中SharedPreferences恰恰可以实现这一点 下面,小编将带领大家通过S ...

  4. bos启动56898服务器配置界面报错

    //文件路径 /easweb/runtime/server/deploy/portal.ear/portal.war/WEB-INF/config/spring/applicationContext- ...

  5. 单向关系中的JoinColumn

    1.person与address的一对一单向关系: 在address中没有特殊的注解. 在Person中对应到数据库里面就有一个指向Address的外键. 我们也可以增加注释指定外键的列的名字,如下: ...

  6. Visual Studio 创建WebServer

    1.文件-->新建-->项目 2.Web-->Visual Studio 2012-->ASP.NET 空Web应用程序 3.右键项目-->添加-->新建项 4.选 ...

  7. HDU 5907 Find Q(简单字符串)

    传送门 Description Byteasar is addicted to the English letter 'q'. Now he comes across a string S consi ...

  8. Python基本数据类型之list

    一.创建列表: li = [] li = list() name_list = ['alex', 'seven', 'eric'] name_list = list(['alex', 'seven', ...

  9. NOIp 0924 水题记

    这场貌似是gcd专场? 第一题很有意思,模拟gcd的过程即可. //0924 candy //by Cydiater //2016.9.24 #include <iostream> #in ...

  10. Nginx系列5之让Nginx支持HTTP1.1

    preface nginx在反向代理HTTP协议的时候,默认使用的是HTTP1.0去向后端服务器获取响应的内容后在返回给客户端. HTTP1.0和HTTP1.1的一个不同之处就是,HTTP1.0不支持 ...