Using GitLab

From MEG Wiki
Jump to navigation Jump to search


In this page you will find information on how to use gitlab in general and for our Epilepsy project in particular. Gitlab is a web based Git repository that provides an opportinty to develop a streamlined project workflow. It is a cloud based sharing center where users working on the same code can compare, develop, pull and push code to the master repository.

Git Useful Links

  1. Cheat sheet
  2. Git Fetch & Merge

Steps to create a gitlab repo

Go to the git lab login page and create a project. If you already have files you can push them using command line instructions below. Otherwise you can start with adding a README, a LICENSE, or a .gitignore to this project. You will need to be owner or have the master permission level for the initial push, as the master branch is automatically protected.

Command line instructions

Git global setup

git config --global "C Ustine"
git config --global ""

Create a new repository

git clone
cd Name_Of_Project
git add
git commit -m "add README"
git push -u origin master

Existing folder

cd existing_folder
git init
git remote add origin
git add .
git commit -m "Initial commit"
git push -u origin master

Existing Git repository

cd existing_repo
git remote add origin
git push -u origin --all
git push -u origin --tags

Basic GitLab commands

Go to the master branch to pull the latest changes from there

git checkout master

Download the latest changes in the project. This is for you to work on an up-to-date copy (it is important to do every time you work on a project), while you setup tracking branches.

(Ex: git pull origin develop-v1)

(REMOTE: origin) (NAME-OF-BRANCH: could be "master" or an existing branch)

Create a branch. Spaces won't be recognized, so you need to use a hyphen or underscore.

git checkout -b NAME-OF-BRANCH

Work on a branch that has already been created

git checkout NAME-OF-BRANCH

To List the name of the branch that you are working on

git branch 

To List the name of the remote

git remote 

View the changes you've made. It's important to be aware of what's happening and what's the status of your changes.

git status

Add changes to commit. You'll see your changes in red when you type "git status".


Send changes to


Delete all changes in the Git repository, but leave unstaged things

git checkout .

Delete all changes in the Git repository, including untracked files

git clean -f

Merge created branch with master branch. You need to be in the created branch.

git checkout NAME-OF-BRANCH
git merge master


We have created a repository of the connectome scripts written and managed for the ECP project. The ECP project is a private repository managed by the ECP MEG team at MCW.

We have currently created two branches of the existing code obtained from the HCP megconnectome database. The "master" branch is our main branch and will only be accessed when we would like to make permanent edits to our code. The developers in the project wil be working on the branch called "develop-v1" which will be our workspace where we store temporary code during trial & development stages. Developers, please pull a copy of the code from the "develop-v1" branch to your workstation to work on the most updated version of the code.

Pull from ECP Repository

git clone OutputDir