- COMP.CS.140
- 2. Welcome to Programming 3: Interfaces and Techniques
- 2.3 Java: Programming Environment
- 2.3.3 Git: The Use on This Course
Git: The Use on This Course¶
Note
In this chapter it is assumed that students are familar with the basics of Git. Please brush up on your Git skills with the material given in the previous chapter, if necessary. The use of repositories is also discussed on 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-spring2024/------
where ------
denotes your Tampere University username.
Huomaa
Personal repositories are created in batches. You need to register to the course in Plussa to get a repository. Getting a your repository may take up a day, but most students should have them quicker.
Start working by cloning your personal 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-spring2024/------
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-spring2024/student_template_project.git
You will always be 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 of the repository is
materials
.In the 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 the command depends on whether you are using an SSH key to log in or not. Without an SSH key, logging in is needed every time you are pulling material from the repository. The command is:git remote add materials git@course-gitlab.tuni.fi:compcs140-spring2024/student_template_project.git
if you are using an SSH key. Otherwise, the URL of the repository is used as is:
git remote add materials https://course-gitlab.tuni.fi/compcs140-spring2024/student_template_project.git
In these instructions it is assumed that GitLab is accessed without an SSH key.
Finally, check with:
git remote -v
that the
materials
repository has been named as you intended:origin https://course-gitlab.tuni.fi/compcs140-spring2024/------ (fetch) origin https://course-gitlab.tuni.fi/compcs140-spring2024/------ (push) materials https://course-gitlab.tuni.fi/compcs140-spring2024/student_template_project.git (fetch) materials https://course-gitlab.tuni.fi/compcs140-spring2024/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
From now on other Git commands, such as fetch
, also know the material repository
with the given 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 updating your personal remote repository:
git push origin
Another remote repository will be later provided for the project work.