Skip to the content.

Assignment Code and Solutions Submission

In the course, you will be submitting your code and/or solutions for the assignments using git, through the Github Classroom tool. In this document, you will be able to find a rough guide on how to use git to submit your work to the online repositories.

A quick introduction to git

If you have worked with git before, and/or you have minimal working git knowledge, you may skip this introductory section. You can also watch the introduction videos (What is Version Control? What is Git? Get going with Git.) at https://git-scm.com/videos. For a complete overview, please refer to the official documentation at https://git-scm.com/. For github-specific introduction check out its Get Started page.

Git is a distributed version control system. The purpose of this tool is to track changes in source files through time, following the development of any software or other project.

Basic git operations

You only need to master a fraction of all of git’s functions in order to successfully submit your work. All of these operations are reviewed next.

Retrieving initial code

To retrieve the initial code, you must clone the repository. This is easily achieved by issuing the following command in a terminal:

git clone http://location/of/repository.git <destination>

With the optional destination parameter, the repository will be cloned to the given path. If not, then a local folder with the same name as the repository name will be created.

Once this operation is finished, you will have the source tree available for working on.

Saving changes to your repository locally

Once you start modifying and/or adding new files to your repository, it will be in a modified state. To make those changes permanent, you have to issue commits. You can only push changes (this is how you will be submitting your solutions later) once you have issued one or more commits.

When you are satisfied (either temporarily or permanently) with changes you made to one or more files in the repository, or even if you want to add a new file, use the git add <files> command. This will mark the selected files as staged, meaning the the next commit will indeed commit those changes.

Please do not add output files (e.g. object files, executables) or temporary files that are produced in the compilation process into the repository. Since these files can be easily recreated (e.g. through compilation) they would just clog the repository without much use.

Now, when you have staged all your changes, you can commit those changes by using the git commit command. Note that if you use this command without any options, it will open up the default terminal text editor. With every commit, you must provide a small message (ideally < 80 characters), expressing what the changes in this commit entail.

Pushing your changes to the remote repository

As git is a distributed version control system, commits that you issue locally in your machine are indeed local. In order to have those changes submitted to the remote server (github in our case), you must do a git push operation. This will send all the local commits you have made that are not in the remote repository yet. Simply issue a git push command anywhere inside your repository folder.

Checking current status and history

At any time, you can check the current status of the repository by using the git status command. This command will show an output that reflects the current state, e.g. which files are modified; if untracked files exist and other states.

You can also look at the commit history by using the git log command. This will show you the complete history of commits and its commit messages.

Getting Started and Submitting an Assignment

Assignments are distributed through github classroom an assignment-specific is posted on Canvas assignment. Accepting the github classroom assignment creates a specific repository for you. Typically, issues for assigmnent steps are created at the same time.

To work on your assignment:

  1. Clone your repository.
  2. Make your modifications and make commits.
  3. Push the commits to the remote repository as you go

When the deadline for the assignment is reached, the latest (most recent) commit to the repository will be taken as the final solution and this is what will be graded. You do not have to worry about multiple submissions; they are acceptable, however only the last commit is taken into account when the deadline is reached.

Browse your repository on github.com to validate that your latest version is there (and you did not forget to push).

Submodules

Git submodules are a great way to integrate working across multiple sources. This may come in handy for larger repositories such as in the project phase.

Read about submodules: