GitLab

Since July 2016 we use [[https://gitlab.inf.unibz.it/|GitLab]] to collaborate.

UNIBZ users have to login to [[https://gitlab.inf.unibz.it/|GitLab]] and their account will be automatically enabled a few minutes after they try their first login.

External users can sign up with their Google, Github, Twitter, Facebook, Bitbucket or Microsoft account.

Here are some instructions on GitLab to ease its use.

If you need support on old repositories created via SVN please [[auth:repository_server|continue reading here]].

Initial setup

Git is usually preinstalled in Linux and Mac, while in Windows you have to [[https://git-scm.com/download/gui/windows | install a client]].

You can have different hosts for different Git repositories which you access via specific username/e-mail. You have to configure your local Git with these settings.

You can either clone/push/pull via HTTPS or SSH. If you chose to use HTTPS, you’ll have to enter your credentials every time, if you choose to use SSH you only insert the password of your SSH key. [[https://docs.gitlab.com/ee/gitlab-basics/start-using-git.html#clone-a-repository|Official documentation]]

The steps for pushing and pulling via SSH Key

Identify or create the SSH key

You need an SSH key that resides on your workstation/notebook.

Check for an existing SSH key

If you already have an SSH key in your computer you will probably find it here:

Linux/macOS : ~/.ssh/id_rsa.pub

Windows : %userprofile%\.ssh\id_rsa.pub

Open the file with a text editor and check if it has contents. Typically it starts with ssh-rsa or ssh-ed25519. If it has contents [[auth:gitlab#add_an_ssh_key|add it to Gitlab]] if it does not exist or is empty generate an SSH key.

Generate an SSH key

Open a terminal on Linux or macOS, or Git Bash on Windows and run the command:

ssh-keygen -t rsa -C "your@email" -b 4096

or

ssh-keygen -t ed25519 -C "your@email"

You can check your e-mail on your [[https://gitlab.inf.unibz.it/profile |Gitlab Profile Settings]] -> Main Settings -> Email

When you are asked for a location and file name you can either keep the default location or choose a new one. If this is your only key we advice you accept the defaults and maintain the file name id_rsa. Should you have several keys you can name them according to your own preferences. [[https://docs.gitlab.com/ee/ssh/README.html|GitLab Official Documentation]]

Add the key to your ssh agent by issuing this commands on Linux/macOS or Git Bash for Windows (adapt to your id_rsa path):

$ eval "$(ssh-agent -s)"
$ ssh-add -K ~/.ssh/id_rsa

Note: You can also use a key generator such as [[http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html|PuTTYgen]] instead of using the terminal. Please refer to the guidelines of the product on how to create the RSA key and the location of the file.

Add an SSH key

Login to Gitlab and go [[https://gitlab.inf.unibz.it/profile |in Gitlab Profile Settings]] → SSH Keys.

In the field Key copy the contents of the file: id_rsa.pub (or any other file containing your key).

Choose a name to identify the key (ex. YourComputerName) and click Add Key, you will see the it listed.

Configure your local Git Client

Before proceeding check if your GIT client is already configured. In Linux/macOS terminal or Windows Git Bash, type the following: <code> git config --global --list</code> <code> git config --list </code>

This command lists any existing GIT repositories configurations. If you have an already existing configuration choose a local configuration (folder specific) for GIT. If you have no other GIT configurations you can configure it globally.

Global configuration

To configure GIT globally using the SSH key inside the terminal/command line, type:

git config --global user.name "Firstname Lastname"
git config --global user.email "your@email"
git config --list

Add your server data in your ssh configuration file. Verify the path is correct

Linux/Mac file ~/.ssh/config:

host gitlab.inf.unibz.it
     HostName gitlab.inf.unibz.it
     user your_username
     IdentityFile ~/.ssh/id_rsa

Windows file ~/.ssh/config:

Host gitlab.inf.unibz.it
     RSAAuthentication yes
     IdentityFile ~/.ssh/config/id_rsa

The data on the global Git configuration is stored in the file (Linux/macOS) ~/.gitconfig or (Windows) C:\Users\username\.gitconfig

The content would be (if configured):

[user]
        name = Lastname Firstname
        email = your@email

Local Configuration

You have to run the commands inside the directory where you want your repository to be. From terminal/command line, type:

cd repository_folder_in_your_computer
git config user.name "Firstname Lastname"
git config user.email "your@email"

Should you receive this message **fatal: not in a git directory**, you have to initialize the folder as a git folder. Issue command : <code> git init </code> and run git commands again.

Basic Git

The logic of git requires you to checkout a project via CLONE. You ensure the project files are up to date by issuing a PULL command. Once the modifications on the project are done, you ADD the changes, you COMMIT them and you PUSH them to the gitlab server.

Create a new project via the web interface

Create a new project via the web interface. https://gitlab.inf.unibz.it/projects/new

Send the checkout URL to other collaborators. You can copy/paste it from the project settings (as SSH or as HTTPS).

git clone git@gitlab.inf.unibz.it:firstname-lastname/my-first-project.git
cd my-first-project
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
cd existing_folder
git init
git remote add origin git@gitlab.inf.unibz.it:firstname-lastname/my-first-project.git
git add .
git commit
git push -u origin master
git checkout master
git pull REMOTE NAME-OF-BRANCH -u

“”

git checkout -b NAME-OF-BRANCH
git checkout NAME-OF-BRANCH
git status

“”

git add CHANGES IN RED
git commit -m "DESCRIBE THE INTENTION OF THE COMMIT"
git push REMOTE NAME-OF-BRANCH
git checkout .
git clean -f
git checkout NAME-OF-BRANCH
git merge master
  • Delete entry in keychain for gitlab.inf.unibz.it
  • Add key again to ssh client : ssh-add -K <key_path>
/var/www/wiki.inf.unibz.it/data/pages/auth_gitlab.txt · Last modified: 2020/04/02 11:25 by apano
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0