[译]git config
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的更多相关文章
- git config 配置
1. git config简介 我们知道config是配置的意思,那么git config命令就是对git进行一些配置.而配置一般都是写在配置文件里面,那么git的配置文件在哪里呢?互动一下,先问下大 ...
- 学习git config配置文件
设置 git status的颜色. git config --global color.status auto 一.Git已经在你的系统中了,你会做一些事情来客户化你的Git环境.你只需要做这些设置一 ...
- git config命令使用
1. git config简介 我们知道config是配置的意思,那么git config命令就是对git进行一些配置.而配置一般都是写在配置文件里面,那么git的配置文件在哪里呢?互动一下,先问下大 ...
- 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 ...
- [译]git pull
git pull把git fetch和git merge压缩成了一条命令. 用法 git pull <remote> 作用和git fetch <remote> &&a ...
- git config proxy
$ export http_proxy=http://proxy.ip.ad.ress:portnumber/ $ export https_proxy=http://proxy.ip.ad.ress ...
- [git]解决:git config --global push.default matching
解决:git config --global push.default matching 这个警告的意思是:需要设置默认push的分支,所以设置好全局push的默认分支就好了.命令如下: 在有git目 ...
- git config配置文件
设置 git status的颜色. git config --global color.status auto 一.Git已经在你的系统中了,你会做一些事情来客户化你的Git环境.你只需要做这些设置一 ...
- git config(转载)
From:http://www.g2w.me/2013/10/cache-github-credential-for-https-repository/ http://openwares.net/li ...
随机推荐
- Android WebService
Web Service简介 Web of Services refers to message-based design frequently found on the Web and in ente ...
- 开发一个jQuery插件——多级联动菜单
引言 开发中,有好多地方用到联动菜单,以前每次遇到联动菜单的时候都去重新写,代码重用率很低,前几天又遇到联动菜单的问题,总结了下,发现可以开发一个联动菜单的功能,以后想用的时候就方便多了.项目中每个页 ...
- ubuntu nginx 安装以及配置文件详解
1.到nginx官网下载源码包.最好下载稳定版本,nginx官网http://www.nginx.org/ 2.安装nginx依赖包运行命令: sudo apt-get install libssl- ...
- 屠蛟之路_蛟灵岛战役(上)_SixthDay
乘风破浪,屠蛟少年们终于到达beta怪蛟大boss的老巢--蛟灵岛. 这是一座孤立在东海深处的荒岛,岛上黑烟缭绕.瘴气重重,屠蛟少年们一登岛,就感受到浓浓的腥味和妖气. 果然,再小心翼翼,走两步居然陷 ...
- 淘宝npm镜像
来源:https://cnodejs.org/topic/4f9904f9407edba21468f31e 镜像使用方法(三种办法任意一种都能解决问题,建议使用第三种,将配置写死,下次用的时候配置还在 ...
- C++ STL中vector的内存机制和性能分析
vecotr是动态数组,顾名思义他可以动态的增加自己的长度. 内存机制: 但是怎样的增加自己的长度? vector有两个函数一个是capacity()返回内存空间即缓冲区的大小,另一个是size()返 ...
- java编程思想-接口总结
"确定接口是理想选择,因而应该总是选择接口而不是具体的类."这其实是一种诱饵.当然,对于创建类,几乎在任何时刻,都可以替代为创建一个接口和一个工厂. 许多人都掉进了这种诱惑的陷阱, ...
- C#----GDI+画图的一些注意和细节
画线: 在矩形rect(0,0,20,20)中的位置Point(0,10),Point(20,10)画线,也就是在矩形的中间画线,线的宽度是20的话,会发现正好线会把矩形占满,说明画线不是向下或者向上 ...
- ecshop 订单-》订单状态
/** * 取得状态列表 * @param string $type 类型:all | order | shipping | payment */ function get_status_list($ ...
- Mac 使用Sublime Text 3搭建java环境
运行效果 运行的时候会在桌面上生成一个 .class文件,可以通过配置文件将生成的.class文件删除. 参考: java环境配置:http://developer.51cto.com/art/201 ...