Git and Gitlab work together

Source: Internet
Author: User
Tags how to use git using git

1. Overview

Before writing this blog, in order to better describe the whole process, I personally tried: from the building to use, the following is the process to illustrate the entire process, the directory structure is as follows:

    1. git Install and build
    2. Git's general operations
    3. The construction of Gitlab
    4. Use of Gitlab

Let's start the whole process.

2.Git article

In fact, as a developer, Git is a must-have skill, perhaps we are familiar with how to use git, the common command of Git also know well, but the construction of the GIT server may not be very concerned about, because these things since we entered the company, the OPS has helped us to do, We just need to know how to use (pull the code, commit the code). But if one day, you go to a company that intends to use Git as a code manager, ask you to build this code management platform, perhaps you will touch a lot of walls, the following gives me the process of building, may save you a lot of unnecessary trouble, to ensure that you build a successful.

2.1Git Server Setup

Environment Preparation:

    • System Environment: CentOS 6.x
    • Software version: git-2.3.1.tar.gz
    • : https://www.kernel.org/pub/software/scm/git/

To compile a git version:

Install dependencies First (all of the following are done in the root directory):

  

Yum Install Perl
TAR-ZXVF git-2.3.1.tar.gz
CD git-2.3.1
Make
Make Install #root用户运行

  Note: If the operating system does not have GCC installed at compile time, use Yum–y install gcc*

In addition, if you use the Yum–y install git installed version of older (1.7.x), after the installation is completed, enter Git--version, will display the corresponding version number, if the actual version number is wrong (git before the operating system), you can first uninstall the previous version, Then make a soft link with the following command:

LN –s/usr/local/bin/git/usr/bin/
2.2 Creating a Git user

Create a git user below with the following command:

Useradd Git–d/home/git
2.3 Installing SSH under a git user

To install SSH under a git user, the command is as follows:

Ssh-keygen –t RSA

Then return to the car.

2.4Installing Gitolite

This is a GIT service management tool that authenticates users with a public key and is able to use configuration files for fine-grained authorization management of repo. Enter the following command:

git clone git://github.com/sitaramc/gitolitemkdir -P ~/bingitolite/Install -to ~/-pk ~/. ssh/id_rsa.pub

Appears as shown, which means success.

2.5 Adding developers

Due to the limited number of machines on hand, I configured the permissions configuration and the Git repository on the same machine, we added the public key under the Git user, and then entered the following command directly under the GIT account:

git clone [email protected]: gitolite-admin.git

  Note: git.company.com here can be used in the actual use of the company domain name or IP.

If you need to enter a password when executing a command, it means that some of the previous configuration errors have occurred and need to be re-verified to continue.

After cloning is complete, two subdirectories appear under the Gitolite-admin directory: Conf and Keydir. Conf is the Gitolite Permissions configuration folder, Keydir is used to place the public key of all users. So now we put the Guest.pub file (the public key generated by the developer computer) into the Keydir directory and edit the conf/gitolite.conf to add the new repo and permissions at the end of the file. Below we add a repo for hdfs-etl, with read and write permissions. The contents are as follows:

Repo hdfs-ETL    RW+ = Guest

  Note: R (read) W (write)

After the modification is complete, we commit the changes to complete the addition of the user and its library, with the following command:

git add confgit add keydirgit commit–m "add repo Diexun-etl,give access Dengjie" git push
2.6 Operating Repo

Below I clone the Hdfs-etl project on the guest's host, the command is as follows:

git clone [email protected]: hdfs-etl.git

If cloning fails under normal network conditions, the public key addition is unsuccessful, and if the cloning succeeds, the Hdfs-etl directory appears. Of course, we can also check the permissions of the operation, the command is as follows:

SSH Info

As shown in the following:

, I have read and write permissions on the machine, consistent with the configured permissions.

2.7 Uninstalling

Any place using SSH or git to log into the GIT server needs to enter a password, indicating that the configuration of the GIT server error, you need to reinstall Gitolite, before reinstalling the previous files, clear the command as follows:

ls grep Xargs RM –FR rm -fr ~/repositories ~/bin  ~/projects.list ~/.  SSH/authorized_keys

Git is here to complete the article, as for the common operation of Git, I think as a developer, should be cooked in the heart, here I will not more than repeat.

3.Gitlab article

GitLab is an open source project for the warehouse management system. Using Git as a code-management tool and a Web service built on top of it, it integrates GitHub's visualization capabilities to facilitate developers working together, and I'm going to use this to expand the description around Gitlab.

3.1Gitlab Construction

Environment Preparation:

Operating system: CentOS 6.x

Gitlab version: 7.8.1

  

Due to the Gitlab official installation process is difficult to succeed (tried many times, various errors, the environment is just a tool, should not spend too much time on this). The following is an integrated installation Kit Bitnami, about the Bitnami introduction, here do not repeat, you can Google to understand.

Bitnami-gitlab:https://downloads.bitnami.com/files/stacks/gitlab/7.8.1-0/bitnami-gitlab-7.8.1-0-linux-x64-installer.run

After the download is complete, we start the installation process, with the following command:

chmod u+x bitnami-gitlab-7.8. 1-0-linux-x64-installer.run
./bitnami-gitlab-7.8.1-0-linux-x64-installer.run

  Note: The machine memory is at least 1G, otherwise it won't run up.

The installation process is listed below:

The installer detects that exists a'git'UserinchThe system. This installer would change the Config
Uration forThis user. Want to continue the installation? [y/N]: Ythe installer detects that exists a'Gitlab_ci'UserinchThe system. This installer'll change the
Configuration forThis user. Want to continue the installation? [y/N]: y----------------------------------------------------------------------------Welcome to the Bitnami Gitlab Stack Setup Wizard.----------------------------------------------------------------------------Select The components of your want toInstall;ClearThe components DoNot WanttoInstall. Click Next When your is ready to continue. Gitlab:y (cannot be edited) GitLab CI [Y/N]: YIs The selection above correct? [y/N]: Y----------------------------------------------------------------------------installation Folderplease, choose a folder toInstallBitnami Gitlab stackselect a folder [/opt/gitlab-7.8.1-0]:----------------------------------------------------------------------------Create Admin accountbitnami Gitlab Stack Admin user Creationemail Address [[email protected]: [Email protected]login [User]: Sapassword:********Please confirm your password:********----------------------------------------------------------------------------Hostname that'll be used to create internal URLs. If This value was incorrect,you may unable to access your Gitlab installation from the other computers. It isadvisable to use a Domain instead of an IP address forcompatibility withdifferent browsers. Domain [10.211.55.30]:D o want to configure mail support? [y/N]: y----------------------------------------------------------------------------Configure SMTP Settingsthis is required so your application can send notifications via email. Default Email provider:[1] gmail[2] Customplease Choose an option [1] :1----------------------------------------------------------------------------Configure SMTP settingsthis data is storedinchThe application configuration files and May is visible toothers. For this reason, it's recommended that DoNot use your personalaccount credentials. Username []: Sapassword:re-Enter:----------------------------------------------------------------------------Setup is now the ready to begin installing Bitnami Gitlab Stack on your computer. do your want to continue? [y/N]: y---------------------------------------------------------------------------- pleasewait whileSetup installs Bitnami Gitlab Stack on your computer. Installing0% ______________ -% ______________ -% #########################################

Here, Gitlab installation is complete.

3.2 Starting the service

The command is as follows:

/opt/gitlab-7.1. 1-0/ctlscript. SH Start # starts /opt/gitlab-7.1. 1-0/ctlscript. SH Restart # restart/opt/gitlab-7.1. 1-0/ctlscript. sh Stop # Stop
4.Gitlab use

Below we log in to Gitlab's visual interface, as follows:

In fact, when the first login, if not configured in the configuration file, there will be a registration function, here for security reasons, I logged in as an administrator, and then removed the registration function in the Setup interface.

The following illustrates the Gitlab usage process:

    • To create a project:

It is important to note that if you belong to a group-level project, which is a multi-person fit project, it is recommended that namespace use group name and visibility default to internal. Let's start by creating a group:

Here we add the group to which the user belongs:

    • The construction of the source warehouse

We then follow the steps to create a project of our own:

Following the steps above, we can create or import a project successfully.

Here, the construction of Gitlab and the creation of the project are completed.

5. Summary

After finishing the data on the hand, I will write an introduction to the Gitlab Pull request workflow, this article will be shared here; if there is any problem, you can add group discussion or send mail to me, I will do my best to answer for you, with June Mutual encouragement!

Git and Gitlab work together

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.