# GitLab

## 1. Access

1. Connect to your tenant workstation using [Remote Desktop](https://docs.ccv.brown.edu/stronghold/usage/windows_workstation) or [FastX](https://docs.ccv.brown.edu/stronghold/usage/linux_workstation).
2. Open a web browser (Firefox or Edge) in your tenant, and type in the url `https://<tenant>-git.stronghold.brown.edu/`&#x20;

* \<tenant> should be replaced by your tenant name. In this page, the example tenant is `dev7`.
* The first time you access gitlab, you will get a warning message about the certificate. You just need click the `Advanced' button`(Figure 1), and then click the `Accept the Risk and Continue` button (Figure 2). After that, you will land at the Sign In page.

![Figure 1 Certificate Warning](https://240799936-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcWdZhwLCll1J0u091B%2F-Md2NnekIlmaz-u4xRBG%2F-Md2O-6PkK-sYrYarYCb%2Fgitlba_certificate_warning.png?alt=media\&token=4ca22432-d106-48a7-ba81-7934ca98b019)

![Figure 2 Accept Risk](https://240799936-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcWdZhwLCll1J0u091B%2F-Md2NnekIlmaz-u4xRBG%2F-Md2OClPbybUFcJMdDzy%2Fgitlab_certificate_accept.png?alt=media\&token=20e88bed-c3c4-4dbb-9ea4-5cac71ed2dab)

* If the GitLab root user is not created yet, you will be directed to the password page (Figure 3) to set the root password.&#x20;

![Figure 3 Set Root Password](https://240799936-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcWdZhwLCll1J0u091B%2F-MeAOyisWQqTMDY39AX8%2F-MeASlvwuImh-UCqQ8p-%2Fgitlab-root-password.png?alt=media\&token=90c5bd9e-063f-4bc3-a887-26918166a1f1)

Enter your username and password to log in (Figure 4)

* * To login as the root, click the 'Standard' tab, and then enter the password for the root user
  * To login as a normal user, click the 'LDAP' tab, and then enter the password for your Brown account

![Figure 4 User Login](https://240799936-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcWdZhwLCll1J0u091B%2F-MeAOyisWQqTMDY39AX8%2F-MeAVYMSevBYANr-Dand%2Fgitlab-user-login.png?alt=media\&token=d4bd732b-55ee-414a-9316-2e0b2a68256b)

## 2. Create a User

A Gitlab admin can create a user.

* Click on "Menu" in the top left and click "Admin". This opens the dashboard in the "Admin Area"

<figure><img src="https://240799936-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LcWdZhwLCll1J0u091B%2Fuploads%2FkZdlliLqrFyROfCs8I9Y%2Fgl_open_admin2.png?alt=media&#x26;token=1c9efd09-9916-4485-9516-28ecf36c71f5" alt=""><figcaption><p>Admin Dashboard</p></figcaption></figure>

* Go to the User tab of the Admin Area (Figure 5), click the `New User` button

![Figure 5 New User](https://240799936-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcWdZhwLCll1J0u091B%2F-MeAXATU9CYHo1jtI8qY%2F-MeAYCyot77apGrNi8u6%2Fgitlab-new-user.png?alt=media\&token=8d78b6ad-259d-4e75-8420-b45ffaf83943)

* Enter the details of a new user
  * Name: Full name of the user (Figure 6)
  * Username: Brown username (Figure 6)
  * Email: the user's Brown email (Figure 6)
  * Access (Figure 7)
    * Admin or Regular

![Figure 6  User Details](https://240799936-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcWdZhwLCll1J0u091B%2F-MeCdZ0gcVKXpZvC4GPX%2F-MeH4a_Ds2vX90sq98tr%2Fgitlab-user-info.png?alt=media\&token=ad0aa7da-d2ad-4ef8-8eb7-4f75b272df16)

![Figure 7 User Access](https://240799936-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcWdZhwLCll1J0u091B%2F-MeH4hwfOYspVZqkqno5%2F-MeH5KTUnqnGvvpj3pvR%2Fgitlab-user-access.png?alt=media\&token=632e8fc0-0f83-4041-bd89-456db24212d9)

## 3. Create a Group and Add Group Members

A user can create a group and add members. An admin can do these from the Admin area as well.

### 3.1 Create a Group

* Click Groups on the top menu, then click Your Groups (Figure 8)

<figure><img src="https://240799936-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LcWdZhwLCll1J0u091B%2Fuploads%2FTFLVHRkLgATpMfUg7bvZ%2Fgl_groups.png?alt=media&#x26;token=bab63689-6750-4a46-ab64-813193f05ab3" alt=""><figcaption></figcaption></figure>

* Click the `Create Group` button (Figure 9)
  * Enter `Group Name`, which automatically populates the `Group URL`(Figure 10)
  * Normally you want to select Internal for `Visibility Level`
* Click the `Create Group` button to complete the creation of the new group

<figure><img src="https://240799936-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LcWdZhwLCll1J0u091B%2Fuploads%2FNCdq3ijRtjvWqWdEbicd%2FCreate_group.png?alt=media&#x26;token=34778115-0b51-4931-9684-01fe082a646b" alt=""><figcaption></figcaption></figure>

### 3.2 Add Group Members

* Choose the group you want to add members to (Figure 9).&#x20;
* Click Members on the left hand side (Figure 11).&#x20;
* Add members to the group (Figure 12)
  * only Maintainer and Owner are able to actually push into the Master Branch of any project.
  * &#x20;Developers are able to create the own branch of a project, but will need to put in a merge request that will then be approved by someone with higher permission.

![Figure 11 Group Management](https://240799936-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcWdZhwLCll1J0u091B%2F-MjVS3NZZQj66sBG0Jph%2F-MjVWeDBD9fCb-gTEOaJ%2Fgitlb-groups-management.png?alt=media\&token=8dc6f3f7-ff1f-40b9-a16e-46e9fb5a1638)

![Figure 12 Group Members](https://240799936-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcWdZhwLCll1J0u091B%2F-MeH5rQ9IDUSvGkYoTGt%2F-MeH7prr_evavOgeTKgR%2Fgitlab-group-members.png?alt=media\&token=beb3ea84-1f71-494b-b05c-59faedb86ca2)

## 4. Create a Project

Here we create a project at group level to allow everyone in your group access to the project and their necessary permission level.

* Go to the group for which the project is to be created for, and then click the `New Project` button (Figure 11)
* Click `Create Blank Project` (Figure 12)
* Enter project details (Figure 13) and then click  the `Create Project` button
  * Project Name: the name of your project, which automatically populates `Project URL`
  * Visibility Level: normally you want to select 'Internal'

![Figure 12 Create a New Project](https://240799936-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcWdZhwLCll1J0u091B%2F-MjVaT63Ux3AsQBpwV4g%2F-MjVfCmjzrDhxPkK6apZ%2Fgitlab-project-new.png?alt=media\&token=94f56918-f02e-401a-bf9e-fbda84adcbe1)

![Figure 13 New Project Details](https://240799936-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcWdZhwLCll1J0u091B%2F-MeH848hdiwS0LRajVtj%2F-MeH8sLmEH8Zw0XaPfgU%2Fgitlab-new-project.png?alt=media\&token=d5914208-5a72-4688-b4a7-36e5cc922215)

## 5. Set up an SSH Key

In order to perform a git push and pull without putting in the username and password, each user will need to setup an ssh key. A user needs do the followings to set up an SSH key:

{% tabs %}
{% tab title="Windows Workstations" %}
Search for git bash on the Start Menu and launch it. This gives you a bash shell for Windows.
{% endtab %}

{% tab title="Linux Workstation" %}
Open a regular terminal on the workstation.
{% endtab %}
{% endtabs %}

1. Open a terminal
2. `cd .`
3. `mkdir .ssh`
4. `cd .ssh`
5. `ssh-keygen -t rsa` (no need to set a password for your ssh key)
6. `cat ~/.ssh/id_rsa.pub` (This will print your public key to the screen. Select and copy it)
7. add your ssh key

   1. Click by your User Name on the top menu bar, and then click the `Preferences` menu (Figure 14)
   2. Click on `SSH Keys` tab on left
   3. Copy your public key of (*id\_rsa.pub)* file (Figure 15) to the key box (Figure 16).

<figure><img src="https://240799936-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LcWdZhwLCll1J0u091B%2Fuploads%2FDIB4g6vKRNw5PM1I6WBN%2FScreenshot%202025-01-24%20at%201.48.36%E2%80%AFPM.png?alt=media&#x26;token=e1d2036f-ae5c-4f12-be14-78b462c649bc" alt=""><figcaption></figcaption></figure>

![Figure 15 id\_rsa.pub](https://240799936-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcWdZhwLCll1J0u091B%2F-Mja5LCC2SgQMQi7z3vU%2F-Mja7p1t5MMkfWdzlCoR%2Fgitlab-terminal-ssh-key.png?alt=media\&token=2276c9c3-63c1-4a77-ac24-27e8349e9c72)

![Figure 16 Add SSH Keys](https://240799936-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcWdZhwLCll1J0u091B%2F-Mja5LCC2SgQMQi7z3vU%2F-Mja6k6uhVn6CheEX1Dt%2Fgitlab-user-ssh-key.png?alt=media\&token=a19c288b-1d1d-4832-8eeb-0366b020da68)

## 6. Common Commands

### 6.1 Git Global Setup

{% hint style="warning" %}
You need to change the git email to your email to push commits as the correct user. The default email is not correct.
{% endhint %}

* git config --global user.name "Your Brown Username"&#x20;
* git config --global user.email "Your Brown Email"

### 6.2 Create a New Repository

* git clone git@\<tenant>-git.stronghold.brown.edu:groupname/project\_name.git&#x20;
* cd project\_name&#x20;
* touch README.md&#x20;
* git add README.md&#x20;
* git commit -m "add README"&#x20;
* git push -u origin master

### 6.3 Push an Existing Directory

* cd existing\_folder&#x20;
* git init&#x20;
* git remote add origin git@\<tenant>-git.stronghold.brown.edu:groupname/project\_name.git&#x20;
* git add .&#x20;
* git commit -m "Initial commit"&#x20;
* git push -u origin master

### 6.4 Push and Existing Repository

* cd existing\_repo&#x20;
* git remote rename origin old-origin&#x20;
* git remote add origin gitsys@\<tenant>-git.stronghold.brown.edu:group/prjoect\_name.git&#x20;
* git push -u origin --all&#x20;
* git push -u origin --tags
