Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The following sections provide instructions for SDC users on setting up GitLab repositories for
committing and sharing their code and any other documents.
GitLab provides an organizational structure of users and repositories managed respectively via
“groups” and “projects” to promote collaboration among teams of SDC users. Groups contain
members with different access levels to their project repositories based on the assigned roles:

...

Role

Read-Only

Read/Write

Guest

(tick)

Reporter

(tick)

Developer

(tick)

Maintainer

(tick)

GitLab Features:

  • Share code with specific team members, your entire team, or different research teams that are also using the SDC.

  • Simplified collaboration with shared read/write access.

  • Manage multiple repositories that are organized and structured in a logical manner.

  • Version control and source code management including:

    • File locking to help prevent conflicts

    • Users can work from their local copy of the code

    • Users can branch code to make changes and then quickly merge it after approval

...

  1. Within your SDC workstation, open a web browser, then navigate to https://gitlab.prod.sdc.dot.gov. This is the URL to the SDC’s internal GitLab.

  2. In the Sign in page, the LDAP login option is selected by default. Enter your SDC credentials as the LDAP username and password, then click Sign in ( in the LDAP Username field, do not enter the “@securedatacommons.com” portion of your SDC username).

  3. The Welcome to GitLab web page is displayed.

  4. Navigating to “Explore Groups” will allow you see all the public groups and projects.

(info) Create a Group

  1. In the Welcome to GitLab web page, select Create a group.

  2. The New group form appears. Enter the name for the new group.

  3. Select the Private option under Visibility level to only allow members in the group to see the group and its projects.

  4. Select Create group.

  5. A success message appears indicating that the group was created. You are now ready to add members to the group.

...

  1. Select the GitLab icon on the upper left to return to the home page.

  2. Select Create a project.

  3. The New project form appears. Enter a name for the project.

  4. Select the Private option under Visibility level, so that the project is only visible to users who are granted explicit access to the project.

  5. Select the Initialize repository with README checkbox to automatically generate a readme file that contains the project’s repository details.

  6. Select Create project.

...

  1. A success message appears indicating that the project repository was created. You are
    now ready to add members to the project.

    Image Modified

(plus) Add Members or Groups to a Project

...

  1. To store your authentication credentials for git, use a hidden folder called “.ssh.” First,
    check to see if the folder exists with ls –a.

    Code Block
    ls –a

    If not, create it using the command mkdir .ssh:

    Code Block
    mkdir .ssh
  2. Confirm this works by entering ls –a to see all objects in the current directory. You should see the .ssh listed:

    Code Block
    ls –a
  3. Generate a new key to store in this location by typing the following command and then hitting the Enter key:

  4. It will output the following message: “Generating public/private rsa key pair.”

  5. It will ask you where to save the file and to enter a passphrase with the following three
    prompts. Hit the Enter key each time (no need to enter anything else) to accept the
    defaults.
    • “Enter file in which to save the key:”
    • “Enter passphrase (empty for no passphrase):”
    • “Enter same passphrase again:”

  6. After the following confirmation messages, the new SSH key is now stored in the .ssh
    folder.
    • “Your identification has been saved in /c/Users/SDCusername/.ssh/id_rsa.”
    • “Your public key has been saved in /c/Users/SDCusername/.ssh/id_rsa.pub.” The default key file name is id_rsa and is saved under the .ssh folder (e.g.,
    C:/Users/[SDCusername]/.ssh/ in Windows; $HOME/.ssh/id_rsa in Linux)

  7. You now need to provide the public part of this key to GitLab by copying the “.pub” part
    of the key. Here are the different options for copying the public SSH key. Option 1:
    On Windows, open the id_rsa.pub file (under the C:/Users/[SDCusername]/.ssh folder) in
    a text editor (Notepad) and copy the entire key by using Select All then Copy. Be careful
    not to accidentally change anything!
    Option 2:
    Copy your public SSH key to the clipboard by using one of the commands below
    depending on your Operating System: Git Bash on Windows:

    Code Block
    cat ~/.ssh/id_rsa.pub | clip

    WSL/GNU/Linux (requires the xclip package):

    Code Block
    xclip -sel clip < ~/.ssh/id_rsa.pub

    If using Jupyter, use the head command. Right-click on the output and click copy:

    Code Block
    head ~/.ssh/id_rsa.pub
  8. From the GitLab home page, add your public SSH key to your GitLab account:
    a. In the upper-right corner, click on your avatar image and then click Settings.
    b. From the left navigation menu, click SSH Keys.
    c. In the Key field, paste your public SSH key.
    d. The Title field will be automatically populated with SDCusername@securedatacommons.com SDCusername@prod.sdc.dot.gov.
    e. Click the Add key button.

  9. To test whether your SSH key was added correctly, run the following command in your
    terminal:

    Code Block
    ssh -T git@scm. internalgitlab.prod.sdc.dot.gov
  10. The first time you connect to GitLab via SSH, you will be asked to verify the authenticity
    of the GitLab host you are connecting to. Type “yes” to add the SDC internal GitLab to
    the list of trusted hosts.

  11. You should see the “Welcome to GitLab, @username!” message.
    NOTE: Once added to the list of known hosts, you will not be asked to validate the
    authenticity of SDC internal GitLab’s host again. Run the above command once more,
    and you should only receive a “Welcome to GitLab, @username!” message.

  12. If the Welcome message does not appear, run SSH in verbose mode by replacing -T with -vvvT to debug the error:

    Code Block
    ssh -vvvT git@scm. internal.sdc.dot.gov