GIT#GIT构建分布式版本控制系统

在这里插入图片描述

注册自己的github账号
https://guides.github.com/activities/hello-world/

一、版本控制

记录开发文件的时间机器、为了更好的开发、挽回代码带来的损失
集中化版本控制系统:Subversion(SVN)
分布式版本控制系统:GIT(三个产品)
github:公共的服务器(要会注册账号https://guides.github.com/activities/hello-world/)
git:纯命令行的软件
gitlab:私有的git web服务器

在这里插入图片描述

二、gitlab构建

[root@gitlab-server ~]# yum -y install curl policycoreutils openssh-server openssh-clients
[root@gitlab-server ~]# systemctl enable sshd
[root@gitlab-server ~]# systemctl start sshd
[root@gitlab-server ~]# yum -y install postfix
[root@gitlab-server ~]# systemctl enable postfix
[root@gitlab-server ~]# systemctl start postfix
[root@gitlab-server ~]# systemctl stop firewalld
[root@gitlab-server ~]# systemctl disable firewalld
自己有包就不下载了
[root@gitlab-server ~]# unzip 6.Git-software.zip
[root@gitlab-server ~]# yum -y localinstall gitlab-ce-9.1.0-ce.0.el7.x86_64.rpm
自动配置文件权限,时间很长
[root@github-server ~]# gitlab-ctl reconfigure

GITLAB占用80端口,访问时直接访问IP就可以(第一次会让你确认root账户登录的密码)
登录需要创建8位密码 kakaopss
创建项目project1之后,保存一种地址(提供2种地址个格式)
SSH  git@github-server:root/project1.git
HTTP  http://root@github-server/root/project1.git
保存这个地址用于命令行,或客户端程序进行下载使用

需要下载的主机需要推送ssh秘钥给gitlab服务器
[root@gitlab-client ~]# ssh-keygen
[root@gitlab-client ~]# cat ~/.ssh/id_rsa.pub
查看到的东西粘贴到github
这里说明一个问题,域名的问题,我们保存的项目地址中gitlab自动做了域名解析
无论是私密文件本地访问,还是公开文件远程访问使用gitlab-server的ip是没问题的
1、本地主机更改主机名称的话,再次生成公钥的会不一样,但是不用再次复制公钥给gitlab服务器
2、远程主机想通过域名进行下载文件,需要做本地域名解析

三、命令行克隆和上传文件的例子

我统一用ip地址,所以就不做域名解析了
克隆服务器的文件:
[root@gitlab-client ~]# git config --global user.name “git”
[root@gitlab-client ~]# git config --global user.email “git@10.11.67.31”
[root@gitlab-client ~]# git clone git@10.11.67.31:/root/project1.git
上传文件:
[root@gitlab-client project1]# cd project1/ 进入工作目录
[root@gitlab-client project1]# echo 123 > sunlizhen.sh 新建文件
[root@gitlab-client project1]# git init 初始化
重新初始化现存的 Git 版本库于 /root/project1/.git/
[root@gitlab-client project1]# git remote add origin git@10.11.67.31:root/project1.git
fatal: 远程 origin 已经存在。
配置远程主机报错了fatal致命的错误,是因为之前已经配置过其他的远程服务器
可以用下面给的命令清除掉,并且重新执行此命令
[root@gitlab-client project1]# git remote rm origin
[root@gitlab-client project1]# git remote add origin git@10.11.67.31:root/project1.git
[root@gitlab-client project1]# git add . 建立当前文件夹下的所有文件,作为准备上传的文件
[root@gitlab-client project1]# git commit -m “kakaops-sunlizhen”
无文件要提交,干净的工作区
如果面的命令不加-m参数,会打开一个vim让你提交上传说明
[root@gitlab-client project1]# git push -u origin master 上传不报错成功之后去浏览器刷新验证

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值