git笔记(本地操作教程)
git笔记(团队协作教程,GitHub操作)
git笔记(IDEA 集成 Git)
git笔记(IDEA 集成 GitHub)
自建代码托管平台-GitLab
额外知识
查看ip
[root@centos-110 ~]# ifconfig
docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
inet6 fe80::42:82ff:fe84:acd6 prefixlen 64 scopeid 0x20<link>
ether 02:42:82:84:ac:d6 txqueuelen 0 (Ethernet)
RX packets 1868 bytes 196634 (192.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 509 bytes 422108 (412.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
//ens192开头的是局域网地址
ens192: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
//下面这个inet
inet 10.0.110.27 netmask 255.255.255.0 broadcast 10.0.110.255
inet6 fe80::5150:b446:b208:85c prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:71:f3:d2 txqueuelen 1000 (Ethernet)
RX packets 5797690 bytes 6776299001 (6.3 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4139413 bytes 5699975143 (5.3 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 4653028 bytes 5928140844 (5.5 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4653028 bytes 5928140844 (5.5 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
veth5573f8f: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::7a:33ff:fe6a:3c05 prefixlen 64 scopeid 0x20<link>
ether 02:7a:33:6a:3c:05 txqueuelen 0 (Ethernet)
RX packets 1868 bytes 222786 (217.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 517 bytes 422764 (412.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
修改ip
[root@centos-110 ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens192
修改主机名
[root@centos-110 ~]# vim /etc/hostname
重启
reboot
配置Windows的hosts文件(ip和 域名映射)
地址:
C:\Windows\System32\drivers\etc\hosts
判断能不能上网,ping一下百度
[root@centos-110 ~]# ping www.baidu.com
Ctrl+L清空控制台
GitLab 简介
GitLab 是由 GitLabInc.开发,使用 MIT 许可证的基于网络的 Git 仓库管理工具,且具有wiki 和 issue 跟踪功能。使用 Git 作为代码管理工具,并在此基础上搭建起来的 web 服务。
GitLab 由乌克兰程序员 DmitriyZaporozhets 和 ValerySizov 开发,它使用 Ruby 语言写成。后来,一些部分用 Go 语言重写。截止 2018 年 5 月,该公司约有 290 名团队成员,以及 2000 多名开源贡献者。GitLab 被 IBM,Sony,JülichResearchCenter,NASA,Alibaba,Invincea,O’ReillyMedia,Leibniz-Rechenzentrum(LRZ),CERN,SpaceX 等组织使用。
GitLab 官网地址
官网地址:https://about.gitlab.com/
安装说明:https://about.gitlab.com/installation/
GitLab 安装
服务器准备
准备一个系统为 CentOS7 以上版本的服务器,要求内存 4G,磁盘 50G。
关闭防火墙,并且配置好主机名和 IP,保证服务器可以上网。
此教程使用虚拟机:主机名:gitlab-server IP 地址:192.168.6.200
安装包准备
Yum 在线安装 gitlab- ce 时,需要下载几百 M 的安装文件,非常耗时,所以最好提前把所需 RPM 包下载到本地,然后使用离线 rpm 的方式安装。
下载地址:
https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-13.10.2-ce.0.el7.x86_64.rpm
注:资料里提供了此 rpm 包,直接将此包上传到服务器/opt/module 目录下即可。
编写安装脚本
安装 gitlab 步骤比较繁琐,因此我们可以参考官网编写 gitlab 的安装脚本。
[root@gitlab-server module]# vim gitlab-install.sh
sudo rpm -ivh /opt/module/gitlab-ce-13.10.2-ce.0.el7.x86_64.rpm
sudo yum install -y curl policycoreutils-python openssh-server cronie
sudo lokkit -s http -s ssh
sudo yum install -y postfix
sudo service postfix start
sudo chkconfig postfix on
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
sudo EXTERNAL_URL="http://gitlab.example.com" yum -y install gitlab-ce
给脚本增加执行权限
[root@gitlab-server module]# chmod +x gitlab-install.sh
[root@gitlab-server module]# ll
总用量 403104
-rw-r--r--. 1 root root 412774002 4 月 7 15:47 gitlab-ce-13.10.2-ce.0.el7.x86_64.rpm
-rwxr-xr-x. 1 root root 416 4 月 7 15:49 gitlab-install.sh
然后执行该脚本,开始安装 gitlab-ce。注意一定要保证服务器可以上网。
[root@gitlab-server module]# ./gitlab-install.sh
警告:/opt/module/gitlab-ce-13.10.2-ce.0.el7.x86_64.rpm: 头 V4
RSA/SHA1 Signature, 密钥 ID f27eab47: NOKEY
准备中... #################################
[100%]
正在升级/安装...
1:gitlab-ce-13.10.2-ce.0.el7
################################# [100%]
。 。 。 。 。 。
初始化 GitLab 服务
执行以下命令初始化 GitLab 服务,过程大概需要几分钟,耐心等待…
[root@gitlab-server module]# gitlab-ctl reconfigure
。 。 。 。 。 。
Running handlers:
Running handlers complete
Chef Client finished, 425/608 resources updated in 03 minutes 08
seconds
gitlab Reconfigured!
启动 GitLab 服务
执行以下命令启动 GitLab 服务,如需停止,执行 gitlab-ctl stop
8080和80端口不能被占用,如果有用可以改gitlab配置文件
[root@gitlab-server module]# gitlab-ctl start
ok: run: alertmanager: (pid 6812) 134s
ok: run: gitaly: (pid 6740) 135s
ok: run: gitlab-monitor: (pid 6765) 135s
ok: run: gitlab-workhorse: (pid 6722) 136s
ok: run: logrotate: (pid 5994) 197s
ok: run: nginx: (pid 5930) 203s
ok: run: node-exporter: (pid 6234) 185s
ok: run: postgres-exporter: (pid 6834) 133s
ok: run: postgresql: (pid 5456) 257s
ok: run: prometheus: (pid 6777) 134s
ok: run: redis: (pid 5327) 263s
ok: run: redis-exporter: (pid 6391) 173s
ok: run: sidekiq: (pid 5797) 215s
ok: run: unicorn: (pid 5728) 221s
使用浏览器访问 GitLab
使用主机名或者 IP 地址即可访问 GitLab 服务。需要提前配一下 windows 的 hosts 文件。
首次登陆之前,需要修改下 GitLab 提供的 root 账户的密码,要求 8 位以上,包含大小写子母和特殊符号。
然后使用修改后的密码登录 GitLab。
GitLab 登录成功。
GitLab 创建远程库
IDEA 集成 GitLab
➢1)安装 GitLab 插件
➢2)设置 GitLab 插件
➢3)push 本地代码到 GitLab 远程库
自定义远程连接
注意:gitlab 网页上复制过来的连接是:http://gitlab.example.com/root/git-test.git,
需要手动修改为:http://gitlab-server/root/git-test.git
选择 gitlab 远程连接,进行 push。
首次向连接 gitlab,需要登录帐号和密码,用 root 帐号和我们修改的密码登录即可。
代码 Push 成功。
只要 GitLab 的远程库连接定义好以后,对 GitLab 远程库进行 pull 和 clone 的操作和Github 和码云一致,此处不再赘述。
彻底卸载GitLab并重装
1、停止gitlab
gitlab-ctl stop
2、卸载gitlab(注意这里写的是gitlab-ce)
rpm -e gitlab-ce
3、查看gitlab进程
ps aux | grep gitlab
4、杀掉第一个进程(就是带有好多…的进程)
杀掉后,在ps aux | grep gitlab确认一遍,还有没有gitlab的进程。若还存在,可以把它的主要组件的进程也杀一边。
5、删除所有包含gitlab文件
find / -name gitlab | xargs rm -rf
当然若你没有全杀权限。那么可以可以把这三个目录给干掉也可以:
rm -rf /opt/gitlab
rm -rf /etc/gitlab
rm -rf /var/log/gitlab
6、重新安装制定版本命令
sudo yum install gitlab-ce-x.x.x #安装指定版本
sudo yum install gitlab-ce-11.4.8