EGR 103/GIT

From PrattWiki
Revision as of 21:36, 9 August 2015 by DukeEgr93 (talk | contribs)
Jump to navigation Jump to search

Introduction

Starting in the Fall of 2015, student in EGR 103 will be using a program called git in order to back up their work for EGR 103 as well as to put their work into a repository that is accessible to the TAs and instructors. While there is naturally some overhead associated with learning how the program works, understanding git is a valuable skill for peole taking EGR 103 to have.

Lab 1 Processes

For EGR 103 for the Fall 2015 semester, students will be using Duke's Git server, gitlab.oit.duke.edu (referred to as Gitlab from this point on), to serve as a host for their git repository. Students will also be pulling a repository from Gitlab which contains files created during lectures and labs as well as files needed for lab each week. The following section goes through the process of setting everything up -- please be careful while following these instructions, and if you have any questions, as a TA or the instructor for help. Getting this set up correctly is about half of the work that will be accomplished during the first lab period for EGR 103.

Setting up your Gitlab account and SSH Keys

To set up your Gitlab account, you will need to log in to Gitlab. To do anything with it, however, you will also need to give Gitlab a piece of code - known as an SSH Key - that Gitlab can use to confirm you are who you say you are. The following will go through the process of setting up your account, generating a key, and adding that key to Gitlab.

  • First, you will need to have a web browser open - it does not matter which one. Navigate to gitlab.oit.duke.edu
  • Do not put your NetID or password in the boxes; instead, click on the "Shibboleth" button: Git Shibboleth.PNG
  • At the Duke Sign In page, Log in using your OIT credentials
  • Click on the Profile Settings icon at the top right - it is the fifth icon from the left and resembles a person: Git Icons.PNG
  • Click on the SSH Keys entry in the menu at the left of the page: Git Keys.PNG
  • Click on the Add SSH Key button at the right of the page: Git AddButton.PNG

Now you will need to generate a key and copy it into this space. To do that, you will need to log in to the Duke Unix machines and then issue Unix commands to have it create a key for you. The following commands will all be in a terminal window:

  • Open MobaXterm and, if need be, start a local terminal
  • At the prompt, type
ssh -XY NetID@login-teer.oit.duke.edu
where NetID is your NetID
  • When prompted, type your password; note that the cursor will not move as you type
  • To create an SSH Key, type:
ssh-keygen -t rsa -C "NetID@duke.edu"
where, again, NetID is your NetID.
  • Accept the default location, which should be /winhomes/NetID/.ssh/id_rsa
  • To see the SSH Key, type:
cat ~/.ssh/id_rsa.pub
  • To copy the SSH Key to your clipboard, simply select the text starting from ssh-rsa and ending with NetID@machine

You will now paste this key into the Key section of the "Add an SSH Key" web page in your browser. You can leave the title as the default case or give it a different name if you wish. Then click the Add Key button: Git AddKey.PNG

From this point forward, when any of the Teer machines interact with your Gitlab account, the keys will be used to verify that you are who you say you are.

Getting the public repository

Next up, you will be creating a directory in your OIT account and then populating it with some public files that you need for lab this week. Each week from here on out, all you will have to do is update your local copy of this folder. For this week, you will need to create a space for the files then tell git where to get the necessary information. All of the commands below will be on the command line in your terminal window:

  • Go to your home directory:
cd ~
  • Create a folder to store the public files:
mkdir EGR103public
  • Change into that folder:
cd EGR103public
  • Tell Unix this will store a repository eventually
git init
Unix should say: "Initialized empty Git repository in /winhomes/NetID/EGR103public/.git/"
  • Tell Unix where to get files from:
git remote add origin git@gitlab.oit.duke.edu:mrg_public/EGR103F15public.git
You can check if this worked by typing git remote -v and the fetch and pull origins should now be correct.
  • Tell git to fetch the files from that repository:
git fetch origin
You may be required to re-enter your NetID and password here; git should then give you some information about what it is doing.
  • Tell Unix the branch you want to pull from by default:
git branch --set-upstream master origin/master
Unix should say: "Branch master set up to track remote branch master from origin."

From this point forward, if you want to get the most up-to-date version of the public repository, all you have to do is change into that directory and pull the files:

cd ~/EGR103public
git pull