? (1)查看远程仓库
? git remote #查看远程仓库
? git remote -v #查看远程仓库地址
? (2)添加远程仓库
? 格式: git remote add 远程仓库名 远程仓库地址
? 1.https格式添加:git remote add origin https://github.com/jiayinghehehe/hehe.git
? 缺点:每次推送数据都要输入用户名和密码
? 2.ssh方式添加:免密钥加密进行交互 (在别人家安装自己的锁,进出方便)
? 好处:可以直接推送数据到远程仓库,保密方式更安全
? 步骤:1)生成密钥对:ssh-keygen 一路回车
? 2)查看密钥对:家目录下的.ssh目录:ll .ssh
? id_rsa #私钥,相当于钥匙
? id_rsa.pub #公钥,相当与锁头
? 3)把公钥放到GitHub仓库中
? 复制公钥到GitHub--》settings设置---》SSH and GPG keys----》SSH keys中(没有就新建一个)
? 4)删除https格式仓库,重新添加ssh方式远程仓库
? git remote add origin git@github.com:jiayinghehehe/hehe.git
? (3)删除远程仓库:git remote remove
? [root@sc git_data]# git remote remove origin
? 格式:git push -u 远程仓库名 想要推送的分支
? 推送主分支到远程仓库:[root@sc git_data]# git push -u origin master
? [root@sc mnt]# git clone git@github.com:jiayinghehehe/hehe.git #https地址也可以
? git pull #重新加载远程仓库数据,因为团队操作,其他成员可能已经更新远程仓库
[root@sc ~]# ssh-copy-id -i .ssh/id_rsa.pub 10.0.0.201(ip地址)#拷贝锁到另一台服务器.ssh/authorized_deys
[root@sc ~]# ssh 10.0.0.201 #登录到另一台服务器
? 内存2g(实验),工作中4g以上,关闭防火墙,关闭selinux
? 通过下载或本地的rpm压缩包方式安装
? 国内镜像:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/
? (1)安装
? [root@gitlab ~]# yum install -y curl policycoreutils-python openssh-server #安装依赖
? [root@gitlab ~]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.2.2-ce.0.el7.x86_64.rpm #下载软件包,本地有直接上传就行
? [root@gitlab ~]# rpm -ivh gitlab-ce-10.2.2-ce.0.el7.x86_64.rpm #安装gitlab
? (2)根据提示编辑配置文件
? [root@gitlab ~]# vim /etc/gitlab/gitlab.rb #编辑配置文件
? external_url ‘http://192.168.1.21‘ #改为自己的IP地址http://10.0.0.200
? [root@gitlab ~]# gitlab-ctl reconfigure #重新加载配置文件,时间较长
? gitlab命令:gitlab-ctl start启动|stop停止|restart重启|status查看状态
? (3)重装完成访问http://10.0.0.200,会首先叫更改密码(root用户),改完后登录
? (1)gitlab是团队合作,创建流程
? 先创建组(oldboy)---》在创建仓库(git_data)---》最后添加使用用户
? (2)在本地创建gitlab远程仓库,通过ssh方式,就可以推送数据
? [root@sc git_data]# git remote add gitlab git@10.0.0.200:oldboy/git_data.git
? [root@sc git_data]# git push -u gitlab master #向gitlab远程仓库推送数据
? 新建一个用户,在组内添加新用户,组内用户都有同样的权限。
? 分支保护,不让组员直接推送数据到主分支,可以推送其他分支到gitlab,再到gitlab上发起合并到主分支请求。
原文:https://www.cnblogs.com/jia-shu/p/13987021.html