Tallaght Campus

Department of Computing

Uploading Lab Work to the CSWD GitHub Repository

This document contains instructions on how to upload lab work using git commands.

Note: Angular brackets with text between them are placeholders, to be replaced in commands by your own particular information. For example, if in a command you saw <your name>, you would not type literally what you see but replace the entire bracket and what is inside it with your actual name e.g. Joe Bloggs (<your name> turns into Joe Bloggs).

  1. Installing git

    Installing git

    In order to use git on your computer, you must have it installed.

    First check if git is installed by running the command git --version in a command line. If this results in a version being reported, git is already installed on your computer and you can skip the following step.

    If git is not installed, you must install it from this page, choosing to download the installer for your operating system.

  2. Using git commands to upload lab work

    Using git commands to upload lab work

    To run git commands, you must open a command line window (cmd or PowerShell in Windows; Terminal in Linux) and type the commands into the window.

    • Before you do anything else, git requires that you identify yourself. Use the following commands to register your name and email address with git:
      git config --global user.name "<your name (not username)>"
      Example: git config --global user.name "Joe Bloggs"
      lets git know your name
      git config --global user.email "<the email address with which you registered with GitHub>"
      Example: git config --global user.email "x00123456@mytudublin.ie"
      lets git know your email (this should be the email you registered on GitHub with)
    • Next, you need to create a copy of your repository on the computer. You do this by cloning the repository with the following command:
      git clone <repository URL>
      Example: git clone https://github.com/CSWD-CompITT/cswd-labs-joe-bloggs
      clones a repository to your computer file system (a repository working directory is created in the directory where the command was executed); the directory name is of the form cswd-labs-joe-bloggs
    • Now unzip file HTMLAndCSS.zip into the repository working directory.
    • To commit your changes (i.e. adding the files from HTMLAndCSS.zip) to the repository locally, use the following two commands, while in the repository working directory as the current directory:
      git add .
      moves any modified files or files new to the repository into the 'staged' state
      git commit -m "<some comment describing the changes>"
      commits the staged files, but does not push them to the online repository
    • To upload the changes to the online repository in GitHub, use the following command, with the repository working directory as the current directory:
      git push
      pushes the commited changes to the online repository
    • To check if the updates to the repository have been successfully pushed to GitHub, open your GitHub account on the WWW and have a look at the contents of the CSWD lab repository.
  3. Uploading further work on the same repository

    Uploading further work on the same repository

    Now you are set up to work on your labs in your repository working directory. You will make changes in the lab files while working on them. When you are finished (completely or just for that work session), repeat the steps starting with git add to update your repository in the cloud. It is a good idea to upload your work regularly.

    If your work is up-to-date in the cloud, you can delete the local repository working directory and start again later with git clone.

    If your work is up-to-date in the cloud, you can work on a different computer, also starting with git clone.

    Short reference information on git can be found in the tutorial 'Git and GitHub'.