10 minutes to build their own Git repository

SpringBoot actual electricity supplier item mall (20k + star) Address: github.com/macrozheng/...

Brief introduction

GitLab is a MIT license to use the web-based Git repository management tool that we can use to build their own Git repository, this article describes how to use Gitlab quickly build Git repository under Linux.

Gitlab server set up

Under Linux (CenterOS7.6) we will Docker way to install Gitlab, for Docker friends can not understand the reference: Developers must-Docker command .

Download Gitlab of Docker image

docker pull gitlab/gitlab-ce
复制代码

Run the following command to start Gitlab

Note that the http service running our Gitlab on port 1080 host, where we will map Gitlab configuration, logs, and data directory to the specified file host of the next clip, to prevent us from losing data after re-create the container.

docker run --detach \
  --publish 10443:443 --publish 1080:80 --publish 1022:22 \
  --name gitlab \
  --restart always \
  --volume /mydata/gitlab/config:/etc/gitlab \
  --volume /mydata/gitlab/logs:/var/log/gitlab \
  --volume /mydata/gitlab/data:/var/opt/gitlab \
  gitlab/gitlab-ce:latest
复制代码

Open the specified port in the firewall

Since Gitlab running on port 1080, so we need to open the port, do not pay attention directly off the firewall, otherwise Gitlab will not start.

# 开启1080端口
firewall-cmd --zone=public --add-port=1080/tcp --permanent 
# 重启防火墙才能生效
systemctl restart firewalld
# 查看已经开放的端口
firewall-cmd --list-ports
复制代码

Access Gitlab

  • Access Address: http://192.168.3.101:1080/
  • Since Gitlab start more slowly, we need to wait about 10 minutes, if not start Gitlab complete access, will receive an error.

  • Can dynamically view the log by docker container start command has started to wonder if gitlab completed.
docker logs gitlab -f
复制代码

Gitlab use

Gitlab start the first visit after completion, will let you reset the password for the root account

After the reset is complete enter your login account password

Select Create a project, create an organization, create an account

Create an organization

First we need to create an organization, then create users and projects are in the organization, so that the user can use the same organization under the project organized.

Create and modify user password

Add to find the user's button

Enter the user name and password to add users

Change the user password in the editing interface

Create a project and add a README file

Assign users to organize

Git client installation and use

Download and install Git client

clone project

  • Find the address of the project clone:

  • Open Git command-line tool:

  • Execute the following command to clone a local project:
git clone http://192.168.3.101:1080/macrozheng/hello.git

复制代码

Submit code

Into the project directory and edit README.md and submit:

# 进入项目工程目录
cd hello/
# 将当前修改的文件添加到暂存区
git add .
# 提交代码
git commit -m "first commit"
复制代码

Pushed to the remote repository

git push
复制代码

Pull a remote repository Code

  • Modify the contents of the readme file on Gitlab:

  • Pulling Code:
git pull
复制代码

Create and submit a local branch

# 切换并从当前分支创建一个dev分支
git checkout -b dev
# 将新创建的dev分支推送到远程仓库
git push origin dev
复制代码

Other commonly used commands

# 切换到dev分支
git checkout dev
# 查看本地仓库文件状况
git status
# 查看本地所有分支
git branch
# 查看提交记录
git log
复制代码

No public

mall project a full tutorial serialized in public concern number the first time to obtain.

No public picture

Guess you like

Origin juejin.im/post/5d63d600e51d453c135c5af3