Install git
On debian/ubuntu based system it rather simple to install git:
apt-get install git
Generate ssh-key
CLI way to generate a key for gitlab. I use a separate keys for each host/server. It makes it easier to delete a key after projects are done. In this example a “fabacademy-gitlab” key pair is created:
So first go your .ssh directory, located in HOME:
cd ~/.ssh
ssh-keygen -t rsa -b 4096 -C "your@mailaddr.ess"
Runnig the command generates output like this:
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa): /home/user/.ssh/fabacademy-gitlab
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/fabacademy-gitlab.
Your public key has been saved in /home/user/.ssh/fabacademy-gitlab.pub.
The key fingerprint is:
SHA256:******************************************* your@mailaddr.ess
The key's randomart image is:
+---[RSA 4096]----+
|* O^ OO . o |
| + X+@ o O |
|. %o S .|
| . O |
| = * S o |
| O . * |
| . . . |
| F o |
| ...|
+----[SHA256]-----+
ssh-config
edit you ssh config file. It’s located mostly in ~/.ssh/config
At the end of the file insert lines like these:
Host gitlab
Hostname gitlab.fabcloud.org
User git
Identityfile ~/.ssh/fabacademy-gitlab
IdentitiesOnly yes
Because this config you can now change the user & hostname parts of the git commands. Change “git@gitlab.fabcloud.org” for “gitlab”
Git global setup
git config --global user.name "your name"
git config --global user.email "your@mailaddr.ess"
Create a new repository
git clone gitlab:academany/fabacademy/2018/labs/fablabamsterdam/students/your-name.git
cd your-name
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
Existing folder
cd existing_folder
git init
git remote add origin gitlab:academany/fabacademy/2018/labs/fablabamsterdam/students/your-name.git
git add .
git commit -m "Initial commit"
git push -u origin master
Existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin gitlab:academany/fabacademy/2018/labs/fablabamsterdam/students/your-name.git
git push -u origin --all
git push -u origin --tags
Adding and commiting changes to gitlab
So from now on you work with the local files. Once you are satisfied with the changes and additions to the site, it’s time to update the repository on gitlab. First you go to the root directory of the project.
cd ~/documentation-theme-jekyll
git pull (for getting the last commits from gitlab, actually it's a command that you have to run before you start editing)
git add . (for all files you haven't added to the repository)
git commit . (now you can write a comment about the changes or additions)
git push (pushes the changes or additions to gitlab)