Chinaunix首页 | 论坛 | 博客
  • 博客访问: 182983
  • 博文数量: 34
  • 博客积分: 869
  • 博客等级: 准尉
  • 技术积分: 375
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-08 15:55
文章分类

全部博文(34)

文章存档

2012年(34)

我的朋友

分类: 项目管理

2012-09-27 14:25:04

git config 用来配置git的环境: 主要的就是用户的邮件地址和用户名 diff编辑器等
先认识三个文件和四个命令参数
文件:
1.一个是用户主目录的.gitconfig 文件。
2.工作目录的.git下面的.gitconfig文件
3./etc/.gitconfig文件
参数:
1. --global              use global config file  <==> 一个是用户主目录的.gitconfig 文件。每个用户有一份
2. --system              use system config file  <==> ./etc/.gitconfig文件  针对所有用户system-wide有效
3. --local               use repository config file   <==> 一个是工作目录的.gitconfig 文件。
4. -f, --file     use given config file         具体制定文件 很少会用

一:默认情况下
--------------------
/home$ git config -l
user.email=zhangx@codeaurora.org
user.name=zhangx
color.ui=true
--------------------
build07:~$ vi .gitconfig
[user]
        email = zx@lll.org
        name = zx
[color]
        ui = true
--------------------
build07:~$ git config --global -l
user.email=zhangx@codeaurora.org
user.name=zhangx
color.ui=true
--------------------
所以默认情况下载非git目录显示的是global的gitconfig

二:在含有.git目录的工作目录下
build07:~$  ls -al
-rw-rw-r--  1 taoq taoq 32398 2012-09-12 11:14 AndroidManifest.xml
-rw-rw-r--  1 taoq taoq  1102 2012-09-12 11:14 Android.mk
-rw-rw-r--  1 taoq taoq  2227 2012-09-12 11:14 CleanSpec.mk
drwxrwxr-x  2 taoq taoq  4096 2012-09-20 17:09 .git/
-rw-rw-r--  1 taoq taoq     0 2012-09-12 11:14 MODULE_LICENSE_APACHE2
-rw-rw-r--  1 taoq taoq 10695 2012-09-12 11:14 NOTICE
-rw-rw-r--  1 taoq taoq    11 2012-09-12 11:14 README.md

build07:~$git config -l
user.email=x@ll.org
user.name=zx
color.ui=true
core.repositoryformatversion=0
core.filemode=true
remote.url=git://git.com/platform/packages/apps/Phone.git
remote.review=review.com:8080
remote.projectname=platform/packages/apps/Phone
remote.fetch=+refs/heads/*:refs/remotes/com/*

build07:~$ vi .git/config
[core]
        repositoryformatversion = 0
        filemode = true
[remote "com"]
        url = git://git.com/platform/packages/apps/Phone.git
        review = review.com:8080
        projectname = platform/packages/apps/Phone
        fetch = +refs/heads/*:refs/remotes/com/*
build07:~$ git config --local -l
core.repositoryformatversion=0
core.filemode=true
remote.url=git://git.com/platform/packages/apps/Phone.git
remote.review=review.com:8080
remote.projectname=platform/packages/apps/Phone
remote.fetch=+refs/heads/*:refs/remotes/com/*
这个时候你会发现在含有.git目录的工作区中运行git config [--global] -l 将会显示.git目录下的config文件内容以及用户主目录底下的.gitconfig文件的合集并且若果有重复的设置以.git目录下面的设置为主。运行git config --local -l  zhihui显示.git目录下的config文件的内容。

最后又一个快速编辑这几个相关文件的快捷方法
1. git config --golbal -e
2 git config --local -e
3. git config --system -e


剩下的就看git help 当然最好的就是man git config






        


阅读(1309) | 评论(0) | 转发(0) |
0

上一篇:linux command question

下一篇:git rebase

给主人留下些什么吧!~~