Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Lab2: Discovering GitLab

IUT d'Orsay, Université Paris-Saclay

Objectives

The goal of this lab is to understand the following concepts and commands:

To get started...

The default main branch name on the Git version used at the IUT is master, but modern versions tend to adopt the name main. To avoid confusion, we will change the name of the main branch to main.

  1. Check the name of your current branch (the main branch) using the following command.

git branch
  1. If your branch is called master, run the following command to change it to main.

git branch -m main
  1. You can change Git’s global configuration on your machine to always use main as the default branch when running git init with the following command.

git config --global init.defaultBranch main

Remote and team-based version control

Getting started with GitLab

As a student at the IUT of Orsay, you already have an account on the IUT GitLab.

git.iut-orsay.fr

To log in, use your short username and your department password.

Personal Access Token

To establish a secure connection between your machine and the IUT GitLab server, we will use a Personal Access Token (PAT), which replaces the old password-based system.

To create a PAT:

  1. Go to your profile by clicking on your avatar (top left), then Edit profile.

Edit profile
  1. In the left menu, click on Access Tokens.

Access Tokens
  1. Add a new token by clicking on Add new token.

Add new token
  1. Give the token a name that reflects the workstation being used (for example, IUTOrsay if you are working on an IUT workstation).

  1. Set an expiration date of one year (the maximum allowed duration) starting from today.

  1. Select all the scopes.

  1. Click on Create personal access token.

Creating a Remote Repo

  1. Create your Remote Repository by clicking on the + button at the top left.

Create new project
  1. Create an empty project with the same name as the one on your machine (qualite-dev-s2-<first-name>-<last-name>).

  2. For the project URL, choose your short username under Users and keep the default proposed URL.

  3. Select the “Private” visibility option for your project and uncheck the option “Initialize repository with a README”; we want a completely empty project.

  1. Click on Create Project.

  2. If you see the following messages, you can ignore them by clicking on Don’t show again for the SSH key and X for Auto DevOps.

SSH Key and Auto DevOps pipeline
  1. Verify that your project is empty (no README). If not, click on Settings > General > Advanced and then Delete in Delete project and restart.

Add a Remote Repo

  1. In your project, click on the Code button on the right.

Code
  1. Copy the URL under the Clone with HTTPS option.

Clone with HTTPS
  1. Go to your local working directory already initialized with git init and open a terminal.

  1. Run the following command and observe.

git remote -v

You will notice that your local project does not yet have a Remote Repo.

  1. Enter the following command, pasting the copied address and adding your username and your PAT in the appropriate places.

git remote add origin https://<your short username>:<Personal Access Token>@git.iut-orsay.fr/<project creator username>/<project name>.git

For example:

git remote add origin https://hla:glpat-1234thisIsYourPAT5678@git.iut-orsay.fr/hla/qualite-dev-s2-hoang-la.git
  1. Run git remote -v again and observe.

Your project now has a Remote Repo.

Fetch and Push

  1. Run git status and observe.

  1. Run git fetch then git status and observe the difference.

  1. Run git push to push all changes from the Local Repo to the Remote Repo.

  1. Go back to GitLab and verify that the Remote Repo has been updated.

  2. Create a new subdirectory called Lab2/ under the root of your project.

  3. Create a new text file of your choice.

  4. Add, commit and push this new modification.

  5. Verify that the Remote Repo contains these new modifications.

  6. Add your instructor to your project by following the instructions below.

Manage members

Clone

Imagine that you are working on another machine that does not yet have a copy of your project.

  1. Move to a different directory that does not contain your Git repository qualite-dev-s2-<first-name>-<last-name>.

  2. Download the Remote Repo with the following command.

git clone https://<your short username>:<Personal Access Token>@git.iut-orsay.fr/<project creator username>/<project name>.git

For example:

git clone https://hla:glpat-1234thisIsYourNewPAT5678@git.iut-orsay.fr/hla/qualite-dev-s2-hoang-la.git
  1. Verify that this new repository matches the Remote Repo, then you can delete it to avoid confusion in the future. It is just an illustration of the git clone command.

  2. Go back to the objectives and check the points you have mastered. Practice the commands and concepts you have not fully understood yet. Ask your instructor for help if needed.