Git: Use on This Course

Note

It is assumed that students are familar with the basics of Git. Please, brush up your Git skills with the material given in the previous chapter, if necessary. The use of repositories is also discussed at the Programming 2 course.

In this course, you need to work with two remote repositories. The first one is your personal repository at:

https://course-gitlab.tuni.fi/compcs140-spring2023/------

Above, ------ denotes your Tampere university username.

Start working by cloning your remote repository as a local repository on your computer. First, open the command prompt and navigate with the cd command to your course directory. Second, copy the remote repository with Git’s clone command:

git clone https://course-gitlab.tuni.fi/compcs140-spring2023/------

The second remote repository contains the code templates for the programming exercises and other material. This repository is at:

https://course-gitlab.tuni.fi/compcs140-spring2023/student_template_project.git

You will be always notified, if a programming exercise has material prepared by the course staff.

Since the prepared material is needed frequently, your workflow will be smoother, if you define a name for the second remote repository with Git’s remote command as follows:

  • Come up with a good name for the repository. The following examples assume that the name is of the repository is materials.

  • In command prompt, navigate with the cd command to your local repository.

  • Name the remote material repository with Git’s remote command. Please, note that the form of command the command depends of whether you are using a SSH key to log in or not. Without the SSH key, you must log in always, when you are pulling material from the repository. The command is:

    git remote add materials git@course-gitlab.tuni.fi:compcs140-spring2023/student_template_project.git
    

    if you are using a SSH key. Otherwise, the URL of the repository is used as it is:

    git remote add materials https://course-gitlab.tuni.fi/compcs140-spring2023/student_template_project.git
    

    It is assumed here that the GitLab is accessed without a SSH key.

  • Finally, check:

    git remote -v
    

    that the material repository has been named as you intended:

    origin https://course-gitlab.tuni.fi/compcs140-spring2023/------ (fetch)
    origin https://course-gitlab.tuni.fi/compcs140-spring2023/------ (push)
    materials https://course-gitlab.tuni.fi/compcs140-spring2023/student_template_project.git (fetch)
    materials https://course-gitlab.tuni.fi/compcs140-spring2023/student_template_project.git (push)
    

    Git has automatically named your local repository as origin during the cloning.

Git’s pull command is now less cumbersome and, therefore, it is easier to merge the prepared material to your local repository:

git pull materials main

Also other Git commands, such as fetch, know from now on the material repository with the new name.

Please, note that you neither need nor can push to the material repository. To work with the material, you only need to pull from the material repository. Give the push command to Git only, when you update your personal remote repository:

git push origin

Another remote repository will be later provided for the project work.