Hello GitlabΒΆ
This exercise guides you through the process of setting up everything so that you can submit the assignment. What we expect you have done before you submit:
- Find your project repository in Gitlab
- Clone the repository to your computer
- Save your SSH keys to Gitlab
- Make a commit to the repository
- Push the commit to Gitlab
- Paste the commit hash to the input below
Detailed Instructions
1. Log into https://course-gitlab.tuni.fi/
Logging in requires TUNI authentication. TUNI hosts course-gitlab service to facilitate your studies and research.
2. Find your project
Your own repository is at: https://course-gitlab.tuni.fi/compcs300-october-YEAR/YOUR_USERNAME If not found, please contact the course personnel.
3. Save your SSH keys
Pulling and pushing is easier and faster when you have saved SSH keys to course-gitlab. The method of generating ssh-key differs from operating system to another, but it is first recommended to check if an ssh-key already exists. There are two instructions, one for Windows and the other for Mac OS + GNU/Linux and other UNIX compatible systems. Please follow the instructions corresponding to your operating system.
Note: ~ refers to the home directory in operating systems.
If all operating systems had a user called student,
the home directory would be
C:\Users\student\ in Windows,
/home/student/ in GNU/Linux and
/Users/student/ in Mac OS.
After ssh-key has been created, it will be in a hidden folder .ssh within the home directory.
Windows
(recommended) Checking if ssh-key already exists
- Open Windows PowerShell
- run command Get-Content ~/.ssh/id_rsa.pub
- If the command prints something starting with ssh-rsa and does not give an error, ssh key already exists, and you may now copy this key to course-gitlab
Generating ssh-key on Windows
- Open Windows PowerShell
- run command ssh-keygen
- The command now asks for the path where to save the key, just press enter
- a passphrase for the key, in this case it is recommended to just leave it empty
- the same passphrase is confirmed, so press enter again
- the command should state that a key has been saved (it might be phrased as your identification)
- To print out the key to copy to course-gitlab run Get-Content ~/.ssh/id_rsa.pub
- you may now copy this key to course-gitlab
Mac OS, GNU/Linux and other UNIX-compatible operating systems (with cat and ssh-keygen)
(recommended) Checking if ssh-key already exists
- Open terminal
- run command cat ~/.ssh/id_rsa.pub
- If the command prints something starting with ssh-rsa and does not give an error, ssh key already exists, and you may now copy this key to course-gitlab
- Open terminal
- run command cat ~/.ssh/id_rsa.pub
- If the command prints something starting with ssh-rsa and does not give an error, ssh key already exists, and you may now copy this key to course-gitlab
Generating ssh-key on Mac OS, GNU/Linux and others
- Open terminal
- run command ssh-keygen
- The command now asks for the path where to save the key, just press enter
- a passphrase for the key, in this case it is recommended to just leave it empty
- the same passphrase is confirmed, so press enter again
- the command should state that a key has been saved (it might be phrased as your identification)
- To print out the key to copy to course-gitlab run cat ~/.ssh/id_rsa.pub
- you may now copy this key to course-gitlab
All operating systems: save the SSH-key to course-gitlab
Here, one example on GNU/Linux when following instructions
student@linux:~$ cat ~/.ssh/id_rsa.pub cat: /home/student/.ssh/id_rsa.pub: No such file or directory student@linux:~$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/student/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/student/.ssh/id_rsa Your public key has been saved in /home/student/.ssh/id_rsa.pub The key fingerprint is: SHA256:MUNoKtafK9W/02VzWdysHrim4EOhKNXEz/v25Chaijc student@linux The key's randomart image is: +---[RSA 3072]----+ | . .. | | =. | | . = o+ o.| | o + . ++ =| | . o o +So . .o| | . . = + . *..| | . . ooo ..= + | | ..E+o.=++ . | | .ooo.++*o | +----[SHA256]-----+ student@linux:~$ cat ~/.ssh/id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDVixpMZhpjmBuOn5BLS9/mpCUcSLbwgxIP9/r5o01/ KWxvTnWZS1bGTmJN98DEhLzL+7zWnB3+cqWSGrKKU++G9cy0FnLbJYW4Ip/q18Y04g9RHNcIy+tEwrUA uCwsRgU0Eg9DPrvRVUmA04ODhA/PxS7kROEly5ryteQqcOmsqDNAg6LjHXUuxb40MUZeZ9fA3/DOlka+ tJJL6XcZ2GEVtRet4BIuEYcfp3ukr1ItwJ9gecEdAA9t/Xy2Q0KdRFd8OvAU+ZGU4GbL9tI3IxyaQCp1 KTCwV21yPUzYVAd82BEmBKvQKgGBgiyGJJEcekqAAVdHglHVpml+LDPjWF+3VRW3GgT918RyRQ676elv j+NvaHAzh8WpXI61620NwepwFEofCZNkwNCJvGcX2rQcI1m5OJNGnSgpqiKkrvrLffrboOml8GUg/qSE sJ5z6q9114cNX655bytYeY5e/6T7NWtYVRgg2cJZTTw2DuHQVtsRoObCF2wj8OyXf4H2gV8= student@linux
- Copy paste the corresponding output from your computer starting from ssh-rsa till the very end.
- Paste here: https://course-gitlab.tuni.fi/-/profile/keys
- Paste the key to the textarea
- Add key button activates. Press it. Your key is now saved. Next, we'll have to clone the repository.
4. Cloning the repository locally
Select a good place for your repo in your computer, and then clone it:
git clone git@course-gitlab.tuni.fi:compcs300-october-YEAR/YOUR_USERNAME.git
During some weekly exercises and the projects,
students will commit their changes to the repository to grade it.
The grading is done with the git url, like in this exercise.
The normal procedure:
git pull # to get the latest changes (not that crucial if submitting alone)
git commit -m "heapify" -a # -m "message to describe the changes"
# -a for all changes, you can also commit only one file or a dir
git push # only now the changes are visible in gitlab, and an exercise can be graded
5. Copying the git commit hash
Once you are ready to submit the exercise, copy the hash of your commit to plussa.
The commit hash can be copied from course-gitlab repository webpage or terminal.
Choose the method you prefer and follow its instructions (or both if you want to learn more about git).
Copying the commit hash from course-gitlab webpage
Start by opening your repository webpage, then click the copy commit SHA button to copy the commit hash to the clipboard If you want to use an older commit hash, open the commits list (In the figure you would click 42 Commits below the repository name). There you will find all the commits and all the commits will have their respective copy commit SHA buttons.
Copying the commit hash from terminal
When you are in the directory of your git repository, run git log
It will open a text listing as in the example below
student@linux:~/path/to/repository$ git log commit cab9f5b0ae657a321a2af84463ccadc4358dcd16 (HEAD -> main, origin/main, origin/HEAD) Author: Student NameThe commit hashes are now listed for each commit, and it is possible to copy it from there.Date: Wed Sep 6 08:47:01 2023 +0300 Good and descriptive commit message commit f8bc013b24fe1caba6aa628517aaf68af47b9775 Author: Student Name Date: Wed Sep 6 08:42:57 2023 +0300 Another good and descriptive commit message commit 13aa92cca8407a2acf7f1ab1edea64e18f412116 Author: Student Name Date: Tue Sep 5 15:30:01 2023 +0300 Another good and descriptive commit message commit 10ef99cd400a02dbbaf2016cf60fe519680c0def Author: Student Name Date: Tue Sep 5 15:26:16 2023 +0300 :
Note! If the next terminal prompt didn't pop up and you don't want to scroll the list up and down with arrow keys, press q to quit the listing.
For learning git, TUNI provides a self-study course. If you want the credits for the git course, register to the course in Sisu (COMP.CS.060), too.
6. Grading the exercise - making your first commit
In this course, most of the grading is automated. Exercises that require you to use git will be graded here in plussa. Once you have pushed your changes to the repository, copy your commit hash and paste it in the exercises grader input. If the commit hash is valid, your repository can then be graded once you click on the "Grade my repository" button. The grading process will start shortly after. Most of the time, the grading is done in a few seconds, but sometimes in more complex exercises it can take up quite a few minutes, so please be patient.
Let's give it a shot!
Make a commit to the repository and push it to Gitlab:
- Inside the local instance of your repository. Open the file
README.md
in your preferred editor - Write "Hello gitlab" to the file
- Save the file
- Use git add to add the file to the staging area:
git add README.md
- Commit the changes to the repository:
git commit -m "my first commit" -a
- Push the commit to Gitlab:
git push
- Copy the commit hash from the terminal or course-gitlab project page
- Paste the commit hash to the input below (titled: "Git commit hash of your submission")
- Click on the "Grade my repository" button below to receive points for going through this introduction.
A+ presents the exercise submission form here.