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.
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.
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.
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 private repository (provided that the SSH keys and configuration is set up) execute a command similar to:
git clone git:SEMESTER/COURSE-USER NAME
where SEMESTER
is the semester and year, COURSE
is the course number and section, USER
is your university id,
and NAME
is an optional name for your course repository name.
For example, a student named
Edward Wong
is enrolled in section 010 of CSC 223 in the Fall of 2019 would execute the
command:
git clone git:fall2019/csc223010-ewong123 csc223-hw
which would create a directory named csc223-hw
for Edward to
work on her assignments. Leaving out the csc223-hw
part would
create a directory named csc223010-ewong123
instead. That is,
the default name of a cloned repository is the name it has on the Linux
server.
There will be various resources provided for starting assignments. This material can be referenced in your private repository. Continuing the previous example, Edward can set up this reference by executing the following command within her local repository (directory).
git remote add assignments git:fall2019/csc223010-assignments
This command only needs to be executed a single time after initially cloning the private repository.
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. Edward can initialize her assignment directory for assignment 1 (provided that the assignments repository is referenced) with the following commands:
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.
Commits in the local private 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
However, not all commits will be treated as an official submission. To
officially submit an assignment, it needs to have an appropriately named
tag (the naming convention for a tag will be given the assignment
description). For example, when Edward wants to submit assignment 1 after
committing any changes in her assignment1
directory, she can
do this:
git push origin master
git tag a1.1
git push --tags
The first command creates a submission tag and the second command pushes that tag to the server so it is available to the professor for grading your submission.
The tag format for the first submission is NAME.VERSION
where
NAME
is the specific name for the assignment and
VERSION
is a version number starting at one. Any subsequent
submission should be named with a version number one higher than the
previous version number. For example, a sequence of submissions could be:
a1.1
, a1.2
, a1.3
. The highest
numbered tag (before the submission deadline) will be considered the final
submission. The submission date an time will be taken from the time of the
tagged commit, not the time that the tag was created.
For certain courses, you may need to access your Git repository from your own machine or the university computers. To use Git on your personal computer, first install Git for Windows only if you use a Windows machine. Then to access your available Git repositories on your personal computer, open Git BASH on Windows or a terminal emulator on OSX or Linux, go to your home directory, and copy your SSH keys to your machine with the following command:
scp USER@csitrd.kutztown.edu:~/.ssh/USER_git_id* ~/.ssh/
where USER
is your university id.
Next you need to add an entry to your .ssh/config
file. If
this file does not exist, then you can copy the one from the Linux server
with the following command:
scp USER@csitrd.kutztown.edu:~/.ssh/config ~/.ssh/
where USER
is your university id.
Otherwise, open the .ssh/config
file and add the following
lines:
Host git
User schwesin
HostName csitrd.kutztown.edu
IdentityFile ~/.ssh/USER_git_id
where USER
is you university id.
git config --global user.name "Edward Wong"
git config --global user.email "ewong123@live.kutztown.edu"
cd
scp ewong123@csitrd.kutztown.edu:~/.ssh/ewong123_git_id* ~/.ssh
scp ewong123@csitrd.kutztown.edu:~/.ssh/config ~/.ssh
git clone git:fall2019/csc223010-ewong123 csc223-hw
cd csc223-hw
git remote add assignments git:fall2019/csc223010-assignments
git fetch assignments
git checkout assignments/master -- assignment1
git add assignment1
git commit -a
git push origin master
git tag a1.1
git push --tags