RDS SU20 - Using Git and GitLab

Overview

Code repositories are hosted on the cloud version of GitLab, GitLab.com. Our GitLab subscription level is Gold, which includes all features offered by GitLab.

Invites to your team’s GitLab group were emailed on Saturday, 6/27. Please let your project manager know if you did not receive an invite after also checking your spam folder (and if you are a UCSD student, checking your campus quarantined emails).

Please refer to the GitLab project creation guide to create projects within your team’s subgroup as needed.

Recommended Reading

GitLab documentation is very helpful. Recommended reading:

RDS Quick Start Repo Guide

Clone

To clone a repository to begin contributing to it, run git clone https://gitlab.com/sdsc-rds/[REPOSITORY PATH].git. This should create a copy of the repo saved locally on your machine. To find the url for a repository that you would like to clone, first navigate to the repository on GitLab. Then, you can click “Clone” in the upper right and choose between SSH or HTTPS.



To use SSH, you will need to have added an SSH key to your GitLab account. To use HTTPS, you will just need to know your username and password.

Branch

You want to keep development to a separate branch on your local machine to avoid conflicts. The general structure during development will look like this

Run:

  1. git checkout dev

  2. git branch [BRANCH NAME]

  3. git checkout [BRANCH NAME]

You have now created a new branch that is a copy of dev and can begin development. Typically you would name the branch something related to what you are implementing.

Make Changes

Make whatever changes might be needed to do what you need. Commit often so you don’t lose your progress.

Push Changes

To push changes, the general workflow is:

  1. checkout dev - git checkout dev

  2. pull to update dev - git pull

  3. checkout your feature branch - git checkout [BRANCH NAME]

  4. merge dev into your feature branch - git merge dev

  5. resolve any merge conflicts

  6. test to make sure everything works

  7. push your feature branch to the repository - git push -u origin [BRANCH NAME]

  8. submit a merge request from your feature branch to dev

Submit a Merge Request

At this point in the guide, you have implemented a new feature and correctly pushed it to the dev branch. It’s not on the master branch yet. After the new feature is deemed to be prod-ready, you want to get those changes onto the master branch to go out into production.

  1. Go to the GitLab repository page

  2. On the left side, click the “Merge Requests” tab

  3. Click “New Merge Request”

  4. Select the source branch to be dev

  5. Select the target branch to be master

  6. Click Compare branches and continue

  7. Fill out the necessary fields

  8. Click submit merge request