GitLab is a GIT server and collaboration tool that keeps the source code of the ]project-open[ application.


Basic GIT Operations Cheat Sheet

ToDo: Move these instructions to the developer section

Cheat Sheet from GitLab 

Installation / Batch Operations

  • Install/clone ]po[ /packages/ folder
  • Update entire /packages/ folder:
    These instructions first create an ~/packages/all-pull.bash file and then executes the file:
    # cd ~/packages/
    # find "$(pwd -P)" -maxdepth 1 -mindepth 1 -type d -exec echo "echo {}; cd {}; git pull" \; > all-pull.bash
    # bash all-pull.bash > all-pull.log 2>&1 &
  • Search for a string in all packages:
    # cd ~/packages/
    # find . -type f -exec grep -il <string> {} \;

Operations on Individual Packages

  • Install/clone a package:
    # cd ~/packages
    # git clone<package>
  • Update individual package to origin/master, possibly merging local changes:
    # cd ~/packages/<package>; git pull
  • Review the changes in the last 5 commits (after a git pull):
    # git log --name-status -5
  • Reset package content to master branch, discarding all local changes:
    # cd ~/packages/<package>
    # git fetch --all
    # git reset --hard origin/master
  • Create a new package:
    Create a new package in -> "New Project":
    - Name: intranet-xxx-yyy
    - Project URL:
    - Project slug: intranet-xxx-yyy
    - Visibility: Public, unless it's a customer specific package
    Now follow the instructions to push an existing folder:
    - cd <existing_folder>
    - git init
    - git remote add origin
    - git add .
    - git commit -m "Initial commit"
    - git push -u origin master

API Cheet Sheat

  • List all projects:
    We need to get the projects in several pages because of a page limit of 100:
    curl --header "Private-Token: xxx" "" | python -m json.tool > projects.json
    curl --header "Private-Token: xxx" "" | python -m json.tool >> projects.json
    curl --header "Private-Token: xxx" "" | python -m json.tool >> projects.json
    curl --header "Private-Token: xxx" "" | python -m json.tool >> projects.json


PostgreSQL Database Cheat Sheet

There are several quirks in the GitLab GUI and API.
A simple way to work around that is to set values directly in the PostgreSQL database:

  • Connect to database:
    From local gitlab server:
    # sudo -u gitlab-psql -i bash -c '/opt/gitlab/embedded/bin/psql -h /var/opt/gitlab/postgresql -d gitlabhq_production'
    psql --host=gitlab --username=gitlab --dbname=gitlabhq_production
  • Restart PostgreSQL:
    # gitlab-ctl restart postgresql
  • List all database tables:
    # sudo -u gitlab-psql -i bash -c '/opt/gitlab/embedded/bin/psql -h /var/opt/gitlab/postgresql -d gitlabhq_production -c "\\d"'
  • Make a project publicly visible:
    update projects set visibility_level = 20 where id=79;
    update projects set visibility_level = 20 where name='intranet-xxx';
    Visibility levels are: 0=private, 10=internal, 20=public


Enable Access to GitLab PostgreSQL

  1. As root login to the PostgreSQL user:
    su - gitlab-psql
  2. In ~/data/postgresql.conf change
    listen_address = ''
    listen_address = '*'
  3. In ~/data/pg_hba.conf add line
    host    all         all        md5
  4. In the PG database (connect locally, see above):
    alter user gitlab with password '<secure_password>';
  5. Open firewall as root:
    firewall-cmd --permanent --add-port=5432/tcp
    firewall-cmd --reload
  6. Restart PG as root:
    gitlab-ctl restart postgresql

Run as root "netstat -nlp | grep 5432". You should see PostgreSQL now listening on a public port.
Then try to connect remotely using the following command:

psql --host=gitlab --username=gitlab --dbname=gitlabhq_production
.. and provide the <secure_password> from above.




  Contact Us
  Project Open Business Solutions S.L.

Calle Aprestadora 19, 12o-2a

08902 Hospitalet de Llobregat (Barcelona)


 Tel Europe: +34 609 953 751
 Tel US: +1 415 200 2465