在使用Git之前,您必须安装并进行一些基本的配置更改.以下是在Ubuntu和Centos Linux上安装Git客户端的步骤.
如果您使用的是Debian基础GNU/Linux发行版,然后 apt-get 命令将完成所需.
[ubuntu ~]$ sudo apt-get install git-core [sudo] password for ubuntu: [ubuntu ~]$ git --version git version 1.8.1.2
如果您使用的是基于RPM的GNU/Linux发行版,那么请使用 yum 命令.
[CentOS ~]$ su - Password: [CentOS ~]# yum -y install git-core [CentOS ~]# git --version git version 1.7.1
Git提供git配置工具,允许您设置配置变量. Git将所有全局配置存储在 .gitconfig 文件中,该文件位于您的主目录中.要将这些配置值设置为全局,请添加 - 全局选项,如果省略 - global 选项,则您的配置将特定于当前Git存储库./p>
您还可以设置系统范围的配置. Git将这些值存储在/etc/gitconfig 文件中,该文件包含系统上每个用户和存储库的配置.要设置这些值,您必须具有root权限并使用 - system 选项.
编译并执行上述代码时,它会生成以下内容结果 :
Git为每次提交使用此信息.
[jerry @ CentOS project] $ git config --global user.name"Jerry Mouse"
Git为每次提交使用此信息.
[jerry @ CentOS project] $ git config - -global user.email"jerry @ it1352.com"
你拉来自远程存储库的最新更改,如果这些更改有所不同,则默认情况下Git会创建合并提交.我们可以通过以下设置来避免这种情况.
jerry @ CentOS project] $ git config --global branch.autosetuprebase always
以下命令在控制台中为Git启用颜色突出显示.
[jerry @ CentOS项目] $ git config --global color.ui true [jerry @ CentOS project] $ git config --global color.status auto [jerry @ CentOS project] $ git config --global color.branch auto
默认情况下,Git使用系统默认编辑器,该编辑器取自VISUAL或EDITOR环境变量.我们可以使用git config配置一个不同的.
[jerry @ CentOS project] $ git config --global core.editor vim
Git不提供默认合并工具,用于将冲突的更改集成到工作树中.我们可以通过启用以下设置来设置默认合并工具.
[jerry @ CentOS project] $ git config --global merge.tool vimdiff
要验证本地存储库的Git设置,请使用 git config -list 命令如下所示.
[jerry @ CentOS~] $ git config --list
以上命令将产生以下结果.
user.name=Jerry Mouse user.email=jerry@it1352.com push.default=nothing branch.autosetuprebase=always color.ui=true color.status=auto color.branch=auto core.editor=vim merge.tool=vimdiff