阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

本地git安装与初始化

96次阅读
没有评论

共计 1891 个字符,预计需要花费 5 分钟才能阅读完成。

系统环境准备

系统:CentOS8

[root@zutuanxue ~]# sestatus -v SELinux status: disabled [root@zutuanxue ~]# systemctl status firewalld ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) Active: inactive (dead) Docs: man:firewalld(1) [root@zutuanxue ~]# dnf repolist 上次元数据过期检查:6:26:44 前,执行于 20200402日 星期四 231737秒。仓库标识 仓库名称 状态 app app 4,681 os os 1,655

Git 安装部署

[root@zutuanxue ~]# dnf install git Git 自带一个 git config 的工具来帮助设置控制 Git 外观和行为的配置变量。这些变量存储在三个不同的位置: [root@zutuanxue ~]# git config --system 系统配置文件 配置内容会存放在 /etc/gitconfig 中,包含系统上每一个用户及他们的仓库的通用配置,需要管理员权限 --global 全局配置文件 配置内容会存放在~/.gitconfig 或者~/.config/git/gitconfig 中 --local 本地的配置文件 配置文件存放在 git 工作目录的.git/config 中 注:配置文件的优先级 local>global>system,可以使用 git config - h 去获取相关帮助,也可以使用 git config --list --show-origin 查看所有的配置及所在的文件。[root@zutuanxue ~]# git config --global user.name "hello" # 定义 git 用户 [root@zutuanxue ~]# git config --global user.email "hello@localhost # 定义 git 使用的邮箱 [root@zutuanxue ~]# git config --global color.ui true # 定义语法高亮 [root@zutuanxue ~]# git config --list user.name=hello user.email=hello@localhost color.ui=true # 查看定义的信息 [root@zutuanxue ~]# pwd /root [root@zutuanxue ~]# cat .gitconfig [user] name = hello email = hello@localhost [color] ui = true

git 初始化

初始化工作目录、主要用来初始化一个空的 git 本地仓库。执行完上面的命令,当前目录下会自动生成.git 隐藏文件夹,

# 建立工作目录 mkdir git_data cd git_data/ # 初始化 git init # 查看工作区状态 git status [root@zutuanxue git_data]# pwd /root/git_data [root@zutuanxue git_data]# git status 位于分支 master 尚无提交 无文件要提交(创建 / 拷贝文件并使用 "git add" 建立跟踪)
隐藏文件介绍:[root@zutuanxue git_data]# pwd /root/git_data [root@zutuanxue git_data]# ls -a . .. .git [root@zutuanxue git_data]# cd .git/ [root@zutuanxue .git]# ls branches config description HEAD hooks info objects refs branches # 分支目录 config # 保存配置信息 description # 仅供 git web 程序使用 HEAD # 记录当前的分支指向 hooks # 包含脚本文件 info # 包含一个全局排除文件(exclude 文件),可以将不想被 git 处理的文件定义到 exclude 文件中 objects # 存放所有数据内容,有 info 和 pack 两个子文件夹(实际也就是本地仓库的目录) refs # 这个目录一般包括三个子文件夹,heads、remotes 和 tags,heads 中的文件标识了项目中的各个分支指向的当前哪一个提交记录 index # 保存暂存区信息,在执行 git init 的时候,这个文件还没有(也就是暂存区的内容)

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-06-09发表,共计1891字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中