Local Version Control

Repository View

Programming exercises use a version control system called Git. Git is a distributed version control system that allows you to track changes in your code. These changes are stored in a repository. A repository is a collection of files and directories that are tracked by Git. How to navigate through the repository and view the code is explained in the following sections. This guide is divided into two parts: one for students and one for instructors. It is demonstrated using course programming exercises, but the same principles apply to exams as well.

Access Repositories as a Student

As a student, you can use the repository to view your course submissions. To access your submissions, you need to navigate to the exercise, press the ‘Code’ button, and click on open-repository-button.

Opening the repository in the student view

Opening the repository (student view)

After pressing the button, you will be redirected to the Current Repository Content page of the repository. This view shows the current content of the repository with the latest changes in a read-only code editor. You can view the code, but you cannot edit it. You can also navigate through the whole code by clicking on the file names in the file browser on the left side. To the right side of the screen, above the problem statement, you can see the result of the submission. You can also copy the repository URI by pressing the ‘Code’ button to clone the repository to your local machine and see the full commit history by pressing the ‘Open Commit History’ button. Finally, you can download the repository as a ZIP file by pressing the ‘Download Repository’ button.

Current Repository Content

Current Repository Content

The Commit History page shows all the commits that you uploaded to the repository. The commits are ordered from the latest to the oldest. You can see the commit message, the author of the commit, the date of the commit, the commit hash and the result of the commit. If you created a submission with multiple commits, you can see all of them here but only the last commit has the result of the submission. Lastly, you can also view the code of the commit by pressing on the commit hash.

Commit History View

Commit History View

By clicking on a commit hash, you are redirected to the Commit Diff page. This page shows the changes that you made in this commit. You can see the changes in the code, the files that have been added, the files that have been deleted and the files that have been modified. Green color indicates the lines that have been added and red color indicates the lines that have been deleted. You can also see the commit message, the author of the commit, the date of the commit and the commit hash.

Commit Diff View

Commit Diff View

Access Repositories as an Instructor

As an instructor, you can use the repository to view the submissions of your students. For this purpose, you need to navigate to the exercise participations page. Here you can see all the students’ participations for the exercise and navigate to the repository of a student by pressing the ‘Code’ button and clicking on open-repository-button. This will show the repository of the student just like it is shown to the student.

Open Repository Button in Participations Page

Open Repository Button in Participations Page

You can also see the repositories for an exercises solution, template and test repositories on the exercise management page. You can navigate to these repositories by pressing the ‘Code’ button and clicking open-repository-button as described above.

Solution, Template and Test Repositories in Exercise Management Page

Solution, Template and Test Repositories in Exercise Management Page

Cloning a repository

You can use Sourcetree, git from the terminal, or any client you like to clone your Git repository. These instructions show you how to clone your repository using Git from the terminal.

From the exercise view, click the code button to display the Clone dialog. Copy the clone URL (either the SSH format or the HTTPS, with or without token). If you are using the SSH protocol, ensure your public key is stored in your Artemis account settings and loaded on the local system to which you are cloning. From a terminal window, change to the local directory where you want to clone your repository.

Paste the command you copied from Bitbucket, for example:

Clone over HTTPS:

git clone https://username@artemis.cit.tum.de/course/documentation-tests.git

Clone over HTTPS with access token:

git clone https://username:accessToken@artemis.cit.tum.de/course/documentation-tests.git

Clone over SSH:

git clone ssh://git@artemis.cit.tum.de/course/documentation-tests.git

If the clone was successful, a new sub-directory appears on your local drive. This directory has the same name as the repository that you cloned. The clone contains the files and metadata that Git requires to maintain the changes you make to the source files.

Choosing between HTTPS and SSH:

  • HTTPS: Easier to set up initially, works through firewalls, but requires entering credentials more frequently.

  • SSH: More secure, doesn’t require entering passwords for each operation once set up, but initial setup can be more complex.

Choose HTTPS if you’re new to Git or working in an environment with strict firewall rules. Choose SSH for enhanced security and convenience in long-term development.

HTTPS access tokens

Instructors can create HTTP access tokens for repository access in Artemis. They are created in the account settings and are used in place of passwords for Git over HTTPS. For every student’s exercise, Artemis automatically generates an access token, only associated with the repository of this particular exercise. You can use these to authenticate to the Artemis Local Version Control.

Token Creation

  1. Go to Profile > Settings > VCS token.

  2. Create a new token

Using SSH keys to secure Git operations

Artemis provides a simple way for users to connect securely to repositories, using SSH to perform Git operations. Next is a small and basic introduction to SSH, and if you already know it, here is a guide on how to create SSH keys. If you already have an SSH key, learn how to add it to your Artemis account here.