简单用法

搭建gitlab
清华的软件库下载:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/

  1. 安装依赖软件
    yum -y install policycoreutils openssh-server openssh-clients postfix
    2.设置postfix开机自启,并启动,postfix支持gitlab发信功能
    systemctl enable postfix && systemctl start postfix

3.安装gitlab
4.修改gitlab配置文件指定服务器ip和自定义端口
复制代码
vim /etc/gitlab/gitlab.rb

gitlab服务器地址+端口

external_url 'http://gitlab.example.com'

改成:

external_url 'http://10.200.117.79:9000'

重置并启动GitLab,执行:

gitlab-ctl reconfigure
gitlab-ctl restart

GitLab遇到ssh修改了默认端口解决方法
GItLab用ssh免密钥认证确实很好用,只是配置的时候发现修改了ssh默认端口(22),则不可达,不少小伙伴都遇到了这个问题。经过一番思考,觉得需要修改服务端配置,这里把具体写个博客,让大家少点坑。

修改步骤

1、修改ssh端口(此步骤略过)
Port 端口
2、修改/etc/gitlab/gitlab.rb [gitlab.yml中的配置会被这个给覆盖]
//在后面修改自己的ssh端口
gitlab_rails['gitlab_shell_ssh_port'] = 21386
3、使其生效
gitlab-ctl reconfigure
默认是22端口,直接访问则不会出现端口的。)

gitlab默认备份路径:
/var/opt/gitlab/backups
默认备份保存时间:
gitlab_rails['backup_keep_time'] = 604800
########################################gitlab基本配置完成
在gitlab创建项目库------web-project
#######################################
本地安装git,上传下载代码 #采用ssh通信的方式,需要将自己的公钥存放在gitlab上
yum install -y git

克隆远程仓库到本地:git clone [email protected]:root/web-project.git
查看所处分支:git branch
删除分支:git branch -d slave
更新代码:git pull
将本地代码上传至gitlab服务器:
提交到本地仓库:
git add .
git commit -a -m "change by jack6-2"
git push (如果push或者pull需要密钥,可能是本地密钥发生改变,需要重新向gitlab提交密钥)

从远程仓库拉取代码:
git pull
如果已经没有更新则会提示:
Already up-to-date.

扫描二维码关注公众号,回复: 11606894 查看本文章

如果本地手动误删除了代码,可以使用代码回滚:
git reset --hard 5f2f66964e06b607f3fb68e16464ee780de99a77
需要回滚到哪个版本可以,可以使用git log查看历史记录

猜你喜欢

转载自blog.51cto.com/13434656/2529751