|NO.Z.00004|——————————|^^ 部署 ^^|——|CI/CD&Git部署.V03|——|Git.Client部署|

一、Git客户端部署
### --- Git-client安装
~~~     安装Git依赖工具

[root@server12 ~]#  yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
~~~     安装Git版本包
 
[root@server12 ~]# yum -y install git git-all git-core
~~~     查看git版本

[root@server12 ~]# git --version
git version 1.8.3.1
二、Git配置
### --- Git配置说明

~~~     Git 提供了一个叫做 git config 的工具,专门用来配置或读取相应的工作环境变量。
~~~     这些环境变量,决定了 Git 在各个环节的具体工作方式和行为。
### --- 这些变量可以存放在以下三个不同的地方:
~~~     # 位置一:
~~~     /etc/gitconfig 文件:系统中对所有用户都普遍适用的配置。
~~~     若使用 git config 时用 --system 选项,读写的就是这个文件。

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

[git@server11 ~]$ ll -a | grep .config
drwxrwxr-x   3 git  git   18 Mar 27 20:15 .config
三、Git用户信息配置
### --- 配置个人的用户名称和电子邮件地址:
~~~     如果用了 --global 选项,那么更改的配置文件就是位于你用户主目录下的那个,
~~~     以后你所有的项目都会默认使用这里配置的用户信息。
~~~     如果要在某个特定的项目中使用其他名字或者电邮,只要去掉 --global 选项重新配置即可,
~~~     新的设定保存在当前项目的 .git/config 文件里。

[root@server12 ~]# git config --global user.name "yanqi"
[root@server12 ~]# git config --global user.email yanqi_vip@yeah.net
[root@server12 ~]# cat .gitconfig 
[user]
    email = yanqi_vip@yeah.net
    name = yanqi
四、Git文本编辑器
### --- 设置Git默认使用的文本编辑器, 
~~~     默认不用设置
~~~     一般可能会是 Vi 或者 Vim。如果你有其他偏好,比如 Emacs 的话,可以重新设置

[root@server12 ~]# git config --global core.editor emacs                        
五、查看git配置信息
### --- 要检查已有的配置信息,可以使用 git config --list 命令:
~~~     有时候会看到重复的变量名,
~~~     那就说明它们来自不同的配置文件(比如 /etc/gitconfig 和 ~/.gitconfig),
~~~     不过最终 Git 实际采用的是最后一个。

[root@server12 ~]#  git config --list
user.email=yanqi_vip@yeah.net
user.name=yanqi
merge.tool=vimdiff
### --- 这些配置我们也可以在 ~/.gitconfig 或 /etc/gitconfig 看到,如下所示:

[root@server12 ~]#  vim ~/.gitconfig
~~~     显示内容如下所示:
[user]
        email = yanqi_vip@yeah.net
        name = yanqi
[merge]
        tool = vimdiff
### --- 也可以直接查阅某个环境变量的设定,只要把特定的名字跟在后面即可,像这样:

[root@server12 ~]# git config user.name                   // 查看信息
yanqi
[root@server12 shell]# git config user.name yanqi         // 更改用户名
### --- 在它的工作目录下输出信息会更详细

[root@server12 shell]#  git config --list
user.email=yanqi_vip@yeah.net
user.name=yanqi
merge.tool=vimdiff
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=git@10.10.10.11:/git-root/shell.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master

 
 
 
 
 
 
 
 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

 

posted on   yanqi_vip  阅读(23)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示