Skip to main content

Git, GitLab and your VM

Background

In this section, we will talk about how to make sure your VM can access content you have on your GitLab/GitHub repositories. While the topics covered within this section are not necessarily unique to a NREC VM-related workflow, some of these commands can be useful.

Access tokens

This section is a placeholder, and will be padded out in the future

Pushing a local directory to a new GitLab UiB repository

Make sure you are in a local directory with the files you want to push. If you have not set up a local git instance, run:

git init

then, add and make a commit to a local stage:

git add . 
git commit -m "First commit"

now you will create the repository, with a branch called "main", by running:

git push --set-upstream https://git.app.uib.no/<path/to/repo> main

the path you set here will define the name of the new repository. E.g. "https://git.app.uib.no/ii/did/docusaurus-mwe" will create a repo called "docusaurus-mwe" in the "did" subgroup of the "ii" subgroup at GitLab UiB.

Cloning your GitHub/GitLab UiB repository to the VM

The easiest way to import files which will be used for hosting your website to the NREC VM is to clone these from a GitHub repository

Cloning a public repository

If you are cloning a public repository, you can run:

git clone <https-link>

The HTTPS link can be found by copying it from the repository page by clicking "Code" and then copying the link under "Clone with HTTPS"

alt text

Cloning from a private GitLab UiB repository

Before cloning, generate an access token to the repository, preferably with limited access (only read, not write). Make sure to cd into a directory on your VM which has write access, then run:

git clone https://gitlab-ci-token:<access-token>@git.app.uib.no/path/to/your/report

If you get the error

fatal: could not create work tree dir 'repo-name': Permission denied

you might be in a directory which does not have write access. Try cd ~ to redirect to your users home folder, and retry the git clone command above.