Knowledge Base

GitLab (Git repository)

We provide a Git repository server:

https://gitlab.act.reading.ac.uk

Git repositories allow you to manage your code:

  • collaborate with other users
  • manage versioning, hence allowing to come back to a previous version
  • create different versions of your code (branches / forks)
  • have a secure storage location for your code
  • make it easy to deploy on another server (simple clone action)

Official documentation

Short introduction on the use of Gitlab

Let’s assume you have some code in the directory /home/users/<username>/mycode/ and you want to create a git repository with this code:

  1. Go and connect to gitlab: https://gitlab.act.reading.ac.uk
  2. If not already setup, you’ll need to create an ssh-key to later connect to git-lab from the linux servers. Follow instructions here.
    Note: it is possible not to use ssh keys, but you’ll then have to put your credentials each time you do a synchronizing action with the server; you’ll also have to use the https git reference. This way of doing is not described in the following.
  3. go to your /home/users/<username>/mycode/ directory on a server (e.g. the cluster)
  4. check that git is running on this server:
    git --version
  5. cd to your directory and start git on this directory:
    cd /home/users/<username>/mycode/
    git init
  6. Add all the files to your git repository and stage the files (commit):
    git add .
    git commit -m "initial commit"
  7. now you can push this directory to gitlab. This will create a new project:
    git push --set-upstream git@gitlab.act.reading.ac.uk:<your username>/<your project name>.git master
    

    Then, as stated, run:

     git remote add origin git@gitlab.act.reading.ac.uk:<your username>/<your project name>.git
  8. The new created project is private by default. Go to the project via a web browser (https://gitlab.act.reading.ac.uk/<username>/<project name>) and share or make it public if you need to.
  9. It is good practice to add a readme.md file at the root of your directory. It will be used by default to describe your project. Read more…
    Readme files can have some text formatting (markdown). Follow the instructions here.

Basic git commands

Working on a code is usually a 3 steps action:

  1. Edit your code locally
  2. Stage and Commit the changes. Comment and changes still recorded locally.
  3. Push the changes to the gitlab repository

Find the related commands below:

View the changes you’ve made
It’s important to be aware of what’s happening and the status of your changes. When you add, change, or delete files/folders, Git knows about it. To check the status of your changes:

git status

View differences
To view the differences between your local, unstaged changes and the repository versions that you cloned or pulled, type:

git diff

Add all changes to commit
To add and commit all local changes in one command:

git add .
git commit -m "COMMENT TO DESCRIBE THE INTENTION OF THE COMMIT"

Send changes to https://gitlab.act.reading.ac.uk
To push all local commits to the remote repository:

git push REMOTE NAME-OF-BRANCH

For example, to push your local commits to the master branch of the origin remote:

git push origin master

Read more git commands here

News
Suggest Content…