2016.09.21 21:25:42字数 949阅读 9,927
Git的安装
Ubuntu系统
sudo apt-get install git
Windows系统
- 下载:https://git-scm.com/download/win
- 安装: 点击下一步
![](https://upload-images.jianshu.io/upload_images/2663172-2fc759242445df10.jpg?imageMogr2/auto-orient/strip|imageView2/2/w/480)
1.jpg
- 在Windows Explorer integration选项中将“Git Bash here”和“Git GUI here”打对勾。
![](https://upload-images.jianshu.io/upload_images/2663172-010371053325826c.jpg?imageMogr2/auto-orient/strip|imageView2/2/w/500)
2.jpg
- 在“Adjusting your PATH environment”选项中,默认即可。
![](https://upload-images.jianshu.io/upload_images/2663172-3c43b5b614032714.jpg?imageMogr2/auto-orient/strip|imageView2/2/w/500)
3.jpg
- 在“Configuring the line ending conversions”选项中,
第一个选项:如果是跨平台项目,在windows系统安装,选择;
第二个选项:如果是跨平台项目,在Unix系统安装,选择;
第三个选项:非跨平台项目,选择。
![](https://upload-images.jianshu.io/upload_images/2663172-0122dfdaff7803a5.jpg?imageMogr2/auto-orient/strip|imageView2/2/w/500)
4.jpg
- finish安装结束,点击桌面的git bash 即可运行
GitLab的搭建
Ubuntu16.04系统
-
安装依赖包,运行命令
sudo apt-get install curl openssh-server ca-certificates postfix
-
执行完成后,出现邮件配置,选择Internet那一项(不带Smarthost的)
![](https://upload-images.jianshu.io/upload_images/2663172-7355490816d8980e.png?imageMogr2/auto-orient/strip|imageView2/2/w/570)
gitlab1.png
- 利用清华大学的镜像https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/来进行主程序的安装。
首先信任 GitLab 的 GPG 公钥:
curl https://packages.gitlab.com/gpg.key 2> /dev/null | sudo apt-key add - &>/dev/null - 利用root用户sudo su ,vim打开文件/etc/apt/sources.list.d/gitlab-ce.list,加入下面一行
deb https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu xenial main - 安装 gitlab-ce:
sudo apt-get update
sudo apt-get install gitlab-ce - 执行命令
sudo gitlab-ctl reconfigure - 打开 sshd 和 postfix 服务
service sshd start
service postfix start - 为了使 GitLab 社区版的 Web 界面可以通过网络进行访问,我们需要允许 80 端口通过防火墙,这个端口是 GitLab 社区版的默认端口。为此需要运行下面的命令
sudo iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT - 检查GitLab是否安装好并且已经正确运行,输入下面的命令
sudo gitlab-ctl status - 如果得到类似下面的结果,则说明GitLab运行正常
run: gitlab-workhorse: (pid 1148) 884s; run: log: (pid 1132) 884s
run: logrotate: (pid 1150) 884s; run: log: (pid 1131) 884s
run: nginx: (pid 1144) 884s; run: log: (pid 1129) 884s
run: postgresql: (pid 1147) 884s; run: log: (pid 1130) 884s
run: redis: (pid 1146) 884s; run: log: (pid 1133) 884s
run: sidekiq: (pid 1145) 884s; run: log: (pid 1128) 884s
run: unicorn: (pid 1149) 885s; run: log: (pid 1134) 885s - 在浏览器地址栏中输入:http://127.0.0.1:8080,即可访问GitLab的Web页面
- 首次使用时,浏览器Web页面会提示设置密码,如下图所示。
![](https://upload-images.jianshu.io/upload_images/2663172-009fb4520c0d52e9.png?imageMogr2/auto-orient/strip|imageView2/2/w/936)
gitlab2.png
- 设置密码password后,点击按钮“Change your password”后,跳转到登录/注册页面,如下图所示。
![](https://upload-images.jianshu.io/upload_images/2663172-aa7a4cf76febf36e.png?imageMogr2/auto-orient/strip|imageView2/2/w/376)
gitlab3.png
- 登录名为root,密码为前面设置的password,登录后进入欢迎页面,如下图所示。
![](https://upload-images.jianshu.io/upload_images/2663172-03e6312ea45788c0.png?imageMogr2/auto-orient/strip|imageView2/2/w/772)
gitlab4.png
- 登录进入系统后,创建一个Group,创建后如下图所示。
![](https://upload-images.jianshu.io/upload_images/2663172-3ccbefa8e55f6d08.png?imageMogr2/auto-orient/strip|imageView2/2/w/585)
gitlab5.png
- 创建用户,进入http://127.0.0.1/users/sign_in,进入首页创建一个新用户。
- 创建好了用户后,会自动引导至用户的主页,点击左边菜单栏中的Profile Settings,进入配置界面,再点击导航栏中的SSH Keys进入密钥的输入界面,如下图所示
![](https://upload-images.jianshu.io/upload_images/2663172-e9bb4d15af02ba24.png?imageMogr2/auto-orient/strip|imageView2/2/w/585)
gitlab6.png
GitLab 的远程访问
- 生成秘钥
ssh-keygen -t rsa -C "你的邮箱"
这样就在主目录下的.ssh目录中生成了两个文件id_rsa和id_rsa.pub。id_rsa中保存的是私钥,id_rsa.pub中保存的是公钥。 - 拷贝公钥到剪切板:
pbcopy <</span> id_rsa.pub
在 个人资料->SSH Keys->Add new 页面中粘贴公钥,就添加完成了。
使用Gitlab新建项目
- 在首页可以点击 new project 进行新建项目
- 如果是团队,可以新建组 new Group 然后邀请成员 Member 新建 项目 New project
更多精彩内容下载简书APP
全部评论7
![](https://upload.jianshu.io/users/upload_avatars/2321103/e8554d11-9710-4897-a4d4-2f1a3dc08092.jpg?imageMogr2/auto-orient/strip|imageView2/1/w/80/h/80)
豪门百里
3楼 2018.01.15 05:28
写得不错,但这个东西有什么用啊真是不知道。
2018.02.25 18:11
很多公司的git项目不想放在github上, 所以这个是一个本地的github 和gitlab的功能是一样的
@冯天鹤 写得不错。其实这篇文章对我只有sudo apt-get install git是有用的。
2016.12.06 00:15
@dongshangtong 你本地需要搭建一个服务环境,用nginx或者apache解析到gitlab
我本地搭建的!我按官网命令操作去按照的!现在我安装好了!我在本地访问到了!我什么用另一台电脑去访问啊!在哪里配置啊?
2016.12.06 11:26
@dongshangtong 访问本地搭建的那台电脑的ip
https://www.jianshu.com/p/92f97939e33a