- COMP.CS.300
- 2. Git
- 2.1 Git and Gitlab
Git and Gitlab¶
Students of the course have access to GitLab https://course-gitlab.tuni.fi, where a remote repository will be created for each student for programming assignments. The repository contains code provided by the course as well as some test material.
If you are new to using Git, you can find information on the section Version control and Git in general of the Programming 2 course. Plussa also contains a whole self-study Git course.
Note that if you program using QtCreator, you can access Git functions directly from the menu Tools/Git. There you can do most common operation directly or start Git Gui from Tools/Git/Git Tools/Git Gui.
Getting the project from GitLab (clone)¶
Here’s a brief summary. You can choose whether to use Git through the command line or with its graphical gui (git gui). Both of these options work in Linux and Windows and are available on linux-desktop. There are also third party Git clients like TortoiseGit, but they are not covered here (but use them, if you like).
If you are familiar with command line terminal, that’s the ”traditional” way to use Git. All Linux machines have this, and the Windows git comes with its own.
If this is the first time you use git, you’ll have to set your name and email address (for commit messages), and possibly also change the default text editor used to edit commit messages (the last one only for Linux users):
git config --global user.name "FirstName LastName" git config --global user.email "firstname.lastname@example.com" git config --global core.editor nano
Choose a suitable directory/folder for you work, and retrieve (clone) the repository:
cd suitable/directory/for/your/work git clone https://URL-to-your-GitLab-repository.git
Getting (cloning) the project from GitLab using Git Gui¶
Git provides you with a graphical user interface to access its functions. It’s not very pretty, but gets things done. And it looks the same both in Linux (like linux-desktop) and Windows.
- Start Git Gui from the Program menu/Start menu (or from command line with command ”git gui”). On Windows you can also start it by right-clicking on a folder where you want to clone your repository and choosing ”Git Gui”.
- Retrieve (clone) the repository by choosing ”Clone existing repository”. To ”source”, add the URL to your GitLab repository. To ”Target”, choose a suitable folder where you want create your local repository. Note! Git Gui requires that you give a folder that does not yet exist, so if you use ”Browse” to enter the folder, add ”/name-you-choose” to the end.
- If this is the first time you use git, you’ll have to set your name and email address (for commit messages). In Git Gui, choose Edit/Options and there User name and Email address (the global ones).
Getting new assignments and course updates to your Git repository¶
As the course progresses, there will be updates to code and tests provided by the course. Similarly new programming assignments will be distributed as updates. You will be notified about the updates with an email message, but if you’ve forgotten to read them, it’s a good idea to try to fetch updates from time to time, especially if you have a proglem, a missing file or similar. The instruction below tell how to configure the update ”upstream” repository and get updates to your git repository.
NOTE! In order to get updates to course files, it’s important that you NEVER edit main.cc or the test files. Otherwise it’s really easy to get into problem when Git tries to merge your changes to course updates. If you really feel you must temporarily edit those files, copy them to new names first, and remember to return them to their original state before getting updates!
Getting course updates using Git Gui¶
- Start Git Gui. Choose ”Open existing directory” and choose your repository on your machine (where you cloned it). In Windows, you can also right-click on the folder and choose ”Git Gui”. Or in QtCreator, you can open your project and choose Tools/Git/Git Tools/Git Gui.
- IF you haven’t done so before, configure the course’s repository
as one of your remote repositories. In Git Gui choose Remote/Add…,
and to ”Name” enter ”upstream” and to ”Location” enter
https://course-gitlab.tuni.fi/compcs300-october-2024/student_template_project.git
This has to be done only once for each local repository. (If you are using Git with ssh connection instead of https change the url togit@course-gitlab.tuni.fi:compcs300-october-2024/student_template_project.git
) - Quit Git Gui and start it again (this is required for things to be updated).
- Fetch the updates from the course’s repository into your local repository by choosing Remote/Fetch from/upstream.
- Merge the updates (make them visible in your files) by choosing Merge/Local merge and clicking Merge. If Git Gui complains about ”invalid revisions”, there’s nothing to update (or some other problem).
- Push the updates to your GitLab repository. Choose Remote/Push and click Push.
Submission¶
In this course, the return of exercises is used Git version control and Plus. The return is made as follows:
- Testing the functionality of the work is also your responsibility, so remember to test locally as well.
- Make sure all your code is added to git!! (git add, git commit)
- Update (push) your code once more to GitLab (git push origin)
- Use a web browser to go to Course-GitLab and make sure that all your files can indeed be found there and the content is correct! (Especially that the latest version must have been pushed to Gitlab, you can get this after making sure, e.g. by checking that on the front page of the Gitlab repository the latest commit message is correct).
- Send to Plussa only when everything is definitely saved in Git.
- Please note that the documentation check is also handled automatically using the docs/readme graders