How to work with the distributed repository system

Code

GitHub, GitLab, and Bitbucket distributed repository systems are convenient for several reasons:

  • It’s easy to coordinate development, run and publish tests through them.
  • They can host open source code so that developers can download copies and modify it in their own way. Thanks to such enthusiasts, new versions of programs appear.
  • This is a useful resource for programmers in employment. The service replaces a developer’s “portfolio”: a person can give access to his repository and show examples of good code.

How to create a repository

Let’s look at the example of GitLab.
To get started, you need to create an account. You can do this on the main page of the site: just enter your name, contact email, and password.

One-click registration is available through your existing Google, GitHub, Twitter, Bitbucket, and Salesforce accounts

After registration, a window with available actions opens. Here you can create a new project or collaborative group, explore other members’ projects, or learn more about GitLab.

The service has a minimalistic interface that can be quickly understood

In a new window, select a project action:

  • Create New: a suitable option for the new repository. It remains to set the name and address, description, availability and configuration of the project.
  • Create according to a ready-made template: just select the project goal and the service will create a repository with the necessary settings. For example, to work with Android or iOS applications.
  • Import a ready-made one from GitHub or Bitbucket.
  • Connect an external repository to GitLab CI/CD.

CI/CD stands for “continuous integration and continuous delivery.” In this approach, frequent small changes are made to the code to speed up the teamwork process.

Advanced users can create a project through the command line, which is the basic tool for working with Git

After entering the basic parameters of the project, click Create project and the repository is ready.

For those who don’t know how to add a repository to an existing one: click the plus sign at the top of the page and select New project/repository.

How to create an SSH key

How to connect a repository to the cloud: you need an SSH key. It allows you not to enter user data every time you commit. To create a key, you need to:

  • Download the Git client to your computer.
  • After installing the client, launch it and type ssh-keygen in the command line.
  • Come up with a name for the key file and remember the save path. The default for Windows is your user folder.
  • Come up with a password for the file. If you don’t need a password, skip the step by pressing the Enter key.
  • Get two files with the key. One is local for you only, the other is public, for copying. Git creates these automatically.
  • image

Git records everything you do. This way you can check what file name you set and where you saved it to

The next step is to find the public key in your folder. It will have a .pub extension – you should open it in a text editor and copy all the text.

Next, go to your GitLab user settings and select the SSH Keys section. Here you need to paste the copied text into the Key field, set the name and expiration date of the key and click Add key.