IntelliJ IDEA使用Git连接GitLab服务器

您所在的位置:网站首页 idea连接github仓库 IntelliJ IDEA使用Git连接GitLab服务器

IntelliJ IDEA使用Git连接GitLab服务器

2023-09-08 20:11| 来源: 网络整理| 查看: 265

1.搭建gitlab

2.使用git迁移项目到gitlab中

3.使用IDEA迁出项目

一:从零搭建gitlab服务器

1.1 GitLab镜像下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/

笔者使用的是CentOS 6.5和gitlab-ce-10.4.2-ce.0.el6.x86_64.rpm,大伙可以根据需要到官网下载相应版本。

1.2 安装gitlab依赖项

 

[root@centos-server-yzr gitlab]#yum install curl policycoreutils-python openssh-server openssh-clients postfix cronie -y

     gitlab安装的时候会要求要有policycoreutils-python库,否则在安装过程中会报错并且提示需要policycoreutils-python库,gitlab使用postfix发送邮件,gitlab支持http和ssh两种协议。

 

 

[root@centos-server-yzr gitlab]# service postfix start#启动postfix

[root@centos-server-yzr gitlab]# chkconfig postfix on#设置为开机

[root@centos-server-yzr gitlab]# lokkit -s http -s ssh#配置iptables开放http和ssh端口,可以使用iptables -L查看

1.3 安装gitlab

使用ssh远程连接工具(XShell)将上面下载的gitlab镜像rpm传输需要安装gitlab的服务器上。之后使用rpm命令进行安装。

 

[root@centos-server-yzr gitlab]# rpm -ivh gitlab-ce-10.4.2-ce.0.el6.x86_64.rpm

1.4 启动gitlab

 

[root@centos-server-yzr gitlab]# gitlab-ctl reconfigure

说明:默认安装登录之后会提示需要重置root密码。可以自己单独设置一个复杂密码后登录。gitlab本身采用80端口,如安装前服务器有启用80,安装完访问会报错。需更改gitlab的默认端口可以修改vim /etc/gitlab/gitlab.rb:external_url 'http://localhost:81',

每次重新配置,都需要执行sudo gitlab-ctl reconfigure  使之生效。

1.5 登录gitlab

打开浏览器输入gitlab服务器的IP地址,本文gitlab服务器的IP地址为http://192.168.199.102/,首次提示修改密码,如下图:

二:使用git迁移项目到gitlab中

2.1 登录gitlab创建一个空的project。

2.2 使用git命令行上传代码。

输入git config --global user.name "root"  输入git config --global user.email "邮箱" --我这里没有输入邮箱 输入git init  输入git remote add origin http://192.168.199.102/root/yangzr.git 输入git add .  输入git commit -m "初始化" 输入git push -u origin master 将代码推送到gitlab端

 

三 使用IDEA开发项目

3.1.配置好git的exe目录路径

3.2.idea中checkou选择git,填上项目路径http://192.168.199.102/root/yangzr.git

3.3.填入项目路径之后,输入账户密码将代码迁出

3.4.使用git提交

新建一个readme文件,使用git提交。

点击Commit File之后会弹出提交文件和提交内容,在最右下面的有Commit和Commit and push按钮,这里需要注意一下使用git的commit之后还需要push一下才会提交到git服务器中(gitlab)。



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3