linux下的git安装及配置

1.安装

$ yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel $ yum -y install git-core $ git --version git version 1.7.1

2.配置

  • /etc/gitconfig 文件:系统中对所有用户都普遍适用的配置。若使用 git config 时用 --system 选项,读写的就是这个文件。
  • ~/.gitconfig 文件:用户目录下的配置文件只适用于该用户。若使用 git config 时用 --global 选项,读写的就是这个文件。
  • 当前项目的 Git 目录中的配置文件(也就是工作目录中的 .git/config 文件):这里的配置仅仅针对当前项目有效。每一个级别的配置都会覆盖上层的相同配置,所以 .git/config 里的配置会覆盖 /etc/gitconfig 中的同名变量。

如果用了 --global 选项,那么更改的配置文件就是位于你用户主目录下的那个,以后你所有的项目都会默认使用这里配置的用户信息。

如果要在某个特定的项目中使用其他名字或者电邮,只要去掉 --global 选项重新配置即可,新的设定保存在当前项目的 .git/config 文件里。

例如:

[root@master ~]# pwd

/root

[root@master ~]# git config --global user.name "maohx"

[root@master ~]# cat .gitconfig 

[user]

name = maohx

[root@master ~]# git config --global user.email [email protected]

[root@master ~]# cat .gitconfig 

[user]

name = maohx

email = [email protected]

[root@master ~]# pqd

-bash: pqd: command not found

[root@master ~]# pwd

/root

[root@master ~]#

猜你喜欢

转载自www.cnblogs.com/code4app/p/8946218.html
今日推荐