1.7. Using Gitlab

1. GitLab

"Git is a version control system for tracking changes in computer files and coordinating work on those files among multiple people. It is primarily used for source code management in software development, but it can be used to keep track of changes in any set of files. As a distributed revision control system, it is aimed at speed, data integrity, and support for distributed, non-linear workflows."  Source : https://en.wikipedia.org/wiki/Git

GitLab is basically a web-based Git repository manager (see https://about.gitlab.com).


Polytech/EII has an installed GitLab platform available here : https://gitlab.polytech.umontpellier.fr



You should be able to connect with your Polytech regular login/password.

From there, you can to browse existing projects, either yours or other's, that have been made available to the world, or to local users.

2. Preparing Eclipse (Atollic) and GitLab

Atollic comes with eGit, an integrated Eclipse plugin that can manage Git requests. You may prefer Git command lines... but this tutorial introduces a very simple approach to using GitLab to archive your project, track changes in source code, and collaborate with other developers.

In order to have Atollic working with GitLab, one must first setup an authentication mechanism which links your Atollic session to your GitLab account with some degree of security. This is done by means of a SSH-RSA key pair (public/private).

Open Window → Preferences and go to the General → Network Connections → SSH2 category:


SSH2 home is the local folder to store private keys. If you're using your own computer the default path is OK.

When using school computers, you should set the SSH2 home to somewhere in your P:\ folder (e.g. P:\.ssh). Doing so, you will be able to access GitLab from any workstation in the school.

Next, open the Key Management tab. Click the Generate RSA Key... button.


Then click the Save Private Key... button.

You can ignore the Passphrase, and authorize the .ssh folder creation. Leave the key name as proposed "id_rsa", without any extension.

This will save the private key into your "SSH2 home" local folder (or on your P:\ drive).


You can make sure by navigating to this folder :

The file "id_rsa" contains your private key. It is a text file you can open with any text editor if you are curious :
For now, go back to Atollic SSH2 window. Then select the whole public key text, et press CTRL-C to get it into clipboard.


Now in the Gitlab web interface go to your user Settings:

Then select SSH Keys:
In the Key field, paste the content of the public key you generated with Atollic. Then press the Add Key button.
This will add associate new SSH key with your GitLab account:
Going back to SSH Keys main window, you should see the newly created key:
You've created a permanent authentication mechanism between Atollic and your GitLab account that will work for all your projects (present and future). There's no need to do the previous operation again for other projects.

3. Using GitLab to archive and share your Atollic projects


3.1. Create a new GitLab project

From GitLab top toolbar, select Projects →Your Projects. Then click the New project button.
You need to give a name to the project. Although that's not mandatory, let-us give the same name as the Atollic project we want to associate with this repository. You can also add a project description if you like, and finally choose which level of privacy you want. In any level of privacy, edits are only possible for project members only.
When you're done, click the Create project button.

You’ll end up with an empty new project as shown below. Leave this page open, but put the navigator window aside for the moment.




3.2. Create a local Git repository for Atollic project


From the project contextual menu, go to Team→Share Project...

Then, choose Git and click Next.


The next step is to configure the local Git Repository that will keep track of code history on your computer. Although this is not recommended, a simple approach is to have a local repository for each individual project. To achieve this, , just select Use or create repository in parent folder of project, then select the project name, and then click the button Create Repository.

When done, click Finish.
If you take a look into the project folder, you will notice that a new \.git folder appeared. This is where Git keeps track for your Git actions. There's also a .gitignore file that is new. This file contains a list of directories and files which are not concerned by Git tracking. Basically, you'll find here the \Debug project folder that contains no source code, and is re-generated each time you build the project.
You'll also notice that Project Explorer appearance has somehow changed:
And finally, you’ll see that the contextual Team menu is now populated with a lot of new possible actions:

3.3. First Commit


The Commit command is used to save your project changes to the local Git repository.

Launch the Commit action

In the Git Staging panel that opens, select all the Unstaged Changes files (CTRL-A) and drag them into the Staged Changes field. Then enter a Commit Message (mandatory) which describes the purpose of committing.

When you're done, click the Commit button .

Again, Project Explorer items look different. Actual display tells you that current project files are in sync with the Git repository information (i.e. no file has been modified since last commit).


3.4. Keep track of code versions


Let-us edit main.c and change a little something in the source code. You can for instance modify the delay of the LED ON state.

The initial code:

 * main.c
 *  Created on: 16 août 2018
 *      Author: Laurent

#define DELAY_ON	20000
#define DELAY_OFF	100000

#include "stm32f0xx.h"

int main(void)
 * main.c
 *  Created on: 16 août 2018
 *      Author: Laurent

#define DELAY_ON	50000    // <-- Longer Delay here
#define DELAY_OFF	100000

#include "stm32f0xx.h"

int main(void)


Save all and build the project. Make sure the build succeeds...

Project Explorer now shows changes by means of the ‘>’ character applied to the tree structure app/src/main.c :

Again, launch the Commit action

In the Git Staging panel, you can see that only main.c is now considered for staging. Enter a Commit Message that describes the purpose of committing, and then click the Commit button.


Open Team Show in History

Select the second commit, and then main.c. You get a detailed view of what has been done:



4. Remote Push to GitLab repository


Open Team → Show in Repositories View

Then, in the Git Repositories panel, Right-Click Remote and select Create Remote…


Give the name you want to the remote server. Select Configure push, and then click OK.


In the next window, click the Change button right to the URI text field. You'll end up with the Select a URI window.

Go back to your Gitlab navigator window, open the project you want to use as a remote repository and click the Copy URL to clipboard button under the Clone button.

Then paste the content of the clipboard in the URI field of the Location frame. Other fields are automatically populated with the correct information as shown below. When you're done, click Finish.
In the Configure Push window, then click Save and Push.
You may have questions regarding host authenticity and known host file creation. Answer Yes to both questions.
The next window then appears for few seconds, showing Push process progress.
And finally, you'll get the Push Result window. If everything goes well, you'll get this. Just click OK to close.
You may observe that Git Repositories panel now displays the GitLab server as remote repository:
Then take a look into the GitLab project window. The project is not empty anymore. Instead, it is populated with project files and ready to be shared.
Click the History button, then select the second commit. You are able to see the edit detail, just like within Atollic. The Push action not only saves the last project state, but also all the Git history:
From now on, you don't have to configure the remote again for this project. You can either:
  • Keep track of your changes locally : Commit
  • Push project onto GitLab for safe archiving and sharing : Commit and Push

5. Importing from GitLab repository

You may also find useful to use GitLab to import existing projects directly into your workspace.
Because it is impossible for Atollic to have two identical projects in the same workspace, you need to restart Atollic with a fresh folder as workspace. That's only necessary for this section, and you may delete that folder when you're done. In the example below, I'm using C:\Atollic\workspace_dummy\ as a temporary empty workspace to illustrate import mechanisms.
From Atollic, open File → Import...
Select Git→Project from Git, then click Next.
Choose the Clone URI when importing from a remote repository, then click Next.
Now, copy/paste the URL from the GitLab project you want to import, to the URI field of the import window. Other fields are automatically filled. When done click Next.
It takes a little while for Atollic to retrieve remote project information. When done, you'll be invited to select the Git project branch to import. For simple projects, it is likely that the only branch available is the master branch. When selected, click Next.
Next, make sure that the destination directory corresponds to your current workspace. Use the Browse button if needed. Then click Next.
At this step, project files have been copied from GitLab into your destination folder, but not yet imported into the Atollic workspace data.
Choose the Import existing Eclipse projects option, then click Next.
Finally click Finish.
The imported project sould appear in the Project Explorer.
You may try a build right away!
If everything goes well, it should build without any additional settings:
As you may have noticed, the imported project is still associated with the Git repository (local & remote). You might want to break this association. For this, simply go to Team→Disconnect .
You can now use the imported project as you like.


In the following tutorials, every time you see this box, you have to commit current project state and then push into a dedicated repository on Gitlab. This special remote repository is provided and owned by teacher, but you'll have maintainer rights so you can basically do whatever you want. It is used to monitor your progression.

This is part of the evaluation process, and since Gitlab info extraction is automated, it is mandatory to use the indicated commit name. Copy/paste that name (without " ") into the Commit Message field of the Git Staging panel.

For example, if the box says so:

  Commit name "This is an example "
  Push onto Gitlab


Commit the project using Commit name as Commit Message as shown here:


For the very first commit (coming next), you'll have to configure the remote repository as explained in the above tutorial, using URI obtained from the remote repository. Then, you'll be able to execute first Push. This will create the master branch onto Gitlab repository.

You only need to configure the remote repository once. We'll use the same project all along the tutorials. For second commit and further, you may simply Commit & Push each time you pass by the red box.

Last advices:

  • Keep all commits in the master branch (i.e. do not create other branches).
  • Check your commits in Gitlab after the push action, especially the first ones, to make sure everything works as it should.