一、Docker部署gitlab_ce(单机版)
1.1 部署脚本
按照下述命令启动 gitlab-ce 容器
|
|
1.2 登录gitlab 与配置
gitlab 容器启动后,等待几分钟,待 gitlab-ce 容器完成初始化完成:
- 在浏览器中访问 http://127.0.0.1:8090 ,进入 gitlab 登录页面;
- 使用 root 用户(初始密码存放在
/data/gitlab/config/initial_root_password
文件中)登录 gitlab 的 Web 页面(登录页面后建议修改root密码);
登录 Web 页面后,设置用户界面语言为 简体中文: 点击页面左上角圆形用户图标 -> Preferences 打开设置页面,下拉页面找到 Localization -> Language 中选择 简体中文 选项, 继续下拉到页面底端, 点击 Save changes 按钮保存修改;
Docker 启动 gitlab 后,默认使用 docker 容器ID 当做 gitlab repo 仓库的 host-name, 通常需要配置 gitlab repo 仓库host-name, 配置方法如下:
|
|
配置 ssh 命令行访问 gitlab (配置支持 git 等工具 使用 ssh 连接gitlab):
|
|
修改配置后需要 进入容器命令行 执行 gitlab 的 reconfigure 命令,详细操作如下:
|
|
至此, gitlab 的安装部署已基本完成, 我们可以创建 group、user、repo 等,并开始使用 gitlab 管理代码。
Tips: 我们可以根据需要, 修改 gitlab 配置, 对于 gitlab 配置 修改,需要注意以下两点
- 在web 页面修改的配置, 在页面点击 保存 按钮保存修改后,配置实时生效;
- 手动修改
/data/gitlab/config/
目录下的配置(如 gitlab.rb ) 后,需登录 gitlab 容器命令行,执行gitlab-ctl reconfigure
命令后方可生效;
二、Windows环境配置Git、TortouseGit连接Github
2.1 Git、TortouseGit安装及配置
-
获取 Git安装程序(https://git-scm.com/downloads) 并安装Git,完整安装步骤此处略过;
-
获取 TortouseGit安装程序(https://tortoisegit.org/download/) 并安装TortouseGit,完整安装步骤此处略过, 也可在下载TortouseGit安装程序(https://tortoisegit.org/download/)下载页面查找中文包下载并安装中午支持;
-
在 桌面 或 任意目录 下点击鼠标右键,在菜单选项列表中选择 TortouseGit -> Settings 打开TortouseGit配置窗口, 在 TortouseGit配置窗口中点击左侧的 General 选项页面,在该页面右侧 中间的 Git For Windows 中 配置 git.ex Path (git.exe程序的目录, Git安装目录下的 bin 目录, 如:
C:Program Files\Git\bin
)
2.2 配置 Git、TortouseGit 以 ssh 秘钥访问 gitlab
-
在 gitlab 系统注册新用户,注册完成后联系管理员激活账号。
-
打开 Git Bash 命令行窗口, 配置 Gitlab 账号及 邮箱等:
|
|
- 创建 ssh 密钥对: 在 Git Bash 命令行窗口中输入如下命令、连续按下回车键
|
|
-
登录 Gitlab 配置 ssh 公钥: 用户登录 Gitlab 后打开 http://your-gitlab-host/-/user_settings/ssh_keys 页面,点击 添加新页面 按钮,将第3步中创建的密钥对的公钥( C:\Users\username.ssh\id_rsa.pub )文件中的 内容(公钥)copy 到 页面 的 密钥 输入框中, 按照页面指引完成添加秘钥。
-
配置 ssh config
|
|
- 打开 Git Bash 命令窗口, Clone 已有 Gitlab repo 到本地进行测试
|
|
执行 Clone 命令时,如果遇到 错误提示:Could not a connect to your authentication, 说明 ssh 代码未启用或未正确配置, 执行以下命令即可解决此错误
|
|