Using Git for course work

Git is a distributed version control system. This document contains a minimal set of commands for using Git to submit assignments. It is not a tutorial or introduction to Git. Consult this Git documentation for an overview of Git.

Preliminaries

Git does not provide access control to repositories. In order to access your repository for the course, you will need a private SSH key and an SSH configuration file.

To set up your SSH files, log into the university Linux server and execute the following command:

~schwesin/bin/git_key_setup.bash

This script creates your SSH key pair with the naming convention USER_git_id, where USER is your university id, sets up your, SSH configuration file, and emails your public key to the professor.

Initial Git configuration

Git needs some configuration information before you can start making commits to your course repository. The minimal configuration requires that you set your name and email address. This can be done by executing the following two commands:

git config --global user.name "Your Name"
git config --global user.email "USER@live.kutztown.edu"

where USER is your university id.

You may optionally choose to set the default text editor that Git will use to create commit messages like so:

git config --global core.editor "nano"

The nano text editor is a decent choice on the Linux server if you are unfamiliar with the other options.

Create a local copy of the repository

Each student has a Git repository for developing and submitting course work. If the course has group projects, each group also has a Git repository for group work. Authorized students can clone, pull from, and push to the given repositories. To clone your repository (provided that the SSH keys and configuration is set up) execute a command similar to:

git clone git-server:spring2020/csc526-501-USER NAME

where USER is your university id, and NAME is an optional name for your course repository name.

Get the assignments repository

There will be various resources provided for starting assignments. This material can be referenced in your private repository by executing the following command from within the local repository:

git remote add assignments git-server:spring2020/csc526-501-assignments

This command only needs to be executed a single time after initially cloning the private repository.

Start an assignment

Each assignment for the course will be in its own subdirectory of your private repository. Typically, there will be an initial set of files for each assignment. This material can be obtained by executing the following commands, using assignment1 as an example:

git fetch assignments
git checkout assignments/master -- assignment1

This retrieves the assignment 1 files from the shared assignments repository and copies the assignment1 directory to the local private repository. Then work on assignment 1 would proceed as a sequence of edits and commits.

Submit an assignment

Commits in the local repository are not reflected on the server's version of the repository. The local changes need to be pushed to the server. The command to do so is:

git push origin master