Difference between revisions of "EGR 103/GIT"

From PrattWiki
Jump to navigation Jump to search
Line 63: Line 63:
 
         merge = refs/heads/master
 
         merge = refs/heads/master
 
</source>
 
</source>
 +
 +
=== Creating your class repository ===
 +
For the next step, you will be working in the browser with the Gitlab page again.  You will be creating a Group - which is the top-level organizational structure for Gitlab - and within that you will be creating a Project.  The project will be where all your files for the class are backed up.  You will be granting access to the instructors and the TAs to view the project for this class -- that will help us help you if need be and will also make it possible for us to grade some of your work online.  Please carefully follow the process below:
 +
* If you don't already have a browser open and pointing at Gitlab, open a browser, navigate to '''gitlab.oit.duke.edu''' and log in using the Shibboleth button. 
 +
* Click the Dashboard icon (top left)
 +
* If there is a tabbed window at right, select the “Groups” tab then click the “New group” button under the tab; if there is not a tabbed window at right, click the New Group button in the dashboard.
 +
* In group path, using YOUR NetID, put in '''NetID_classes'''
 +
* In the details block, write a note to yourself that this is the group where class pages go
 +
* Click the Create Group button - this should create the group and then go to the group’s page
 +
* Click the New project button on the right
 +
* In the Project path, type EGR103
 +
* Make sure the Visibility Level is *Private*
 +
* Click the Create project button
 +
* Click on Settings at left
 +
* Click on Members under settings
 +
* For the next part, you will be adding the instructors and your lab section TAs; their NetIDs will be written on the boards at the front of the room.
 +
** Click on New project member at right
 +
** In the people box, add mrg
 +
** In the Project Access, change to Master
 +
** Click the Add users box
 +
** Repeat for the four TAs and for the Head TA
 +
 +
=== Creating your class directory ===
 +
Finally, you can go back to your Unix account and set up the Unix version of your directory.  Go back into your terminal window and perform the following steps:
 +
* Change into your home directory
 +
cd ~
 +
* Clone your new repository - be sure to replace NetID below with your NetID
 +
git clone git@gitlab.oit.duke.edu:NetID_classes/EGR103.git
 +
From this point forward, you should be able to send your most updated version of your files to the repository by going into your EGR103 directory and then typing
 +
git add .
 +
git commit -a -m 'Message'
 +
git push
 +
You should be able to get a copy of your files from the repository, if you really need to, by going into your EGR103 directory and then typing
 +
git pull
 +
 +
You will typically ''not'' need the '''git pull''' piece as the files on Unix will generally be the most updated.  If you lost files, o edited them in a way that you need to recover an older version, '''git pull''' will be able to help you there.  You '''must''' be sure to use the add, commit, and push commands before you log off the system.  Not only will that back up your work but it will also put the files in a location where the instructors and TAs can see them to potentially help with coding issues you may be having.  Also, sometimes your files will be needed for grading purposes - having the latest and greatest in your repository will make it possible to give you credit for your work.

Revision as of 20:51, 10 August 2015

Introduction

Starting in the Fall of 2015, students 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 ~
  • Tell git to clone a preexisting repository - this will automatically create a folder with the name of the repository and will put the files in it:
git clone git@gitlab.oit.duke.edu:mrg_public/EGR103F15public.git
  • Change the name of the folder to be a little shorter
mv EGR103F15public EGR103public

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

To check, you can look at your configuration file by making sure you are in the EGR103public folder and typing

more .git/config

The output should closely resemble:

[core]
        repositoryformatversion = 0
        filemode = false
        bare = false
        logallrefupdates = true
        ignorecase = true
[remote "origin"]
        url = git@gitlab.oit.duke.edu:mrg_public/EGR103F15public.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master

Creating your class repository

For the next step, you will be working in the browser with the Gitlab page again. You will be creating a Group - which is the top-level organizational structure for Gitlab - and within that you will be creating a Project. The project will be where all your files for the class are backed up. You will be granting access to the instructors and the TAs to view the project for this class -- that will help us help you if need be and will also make it possible for us to grade some of your work online. Please carefully follow the process below:

  • If you don't already have a browser open and pointing at Gitlab, open a browser, navigate to gitlab.oit.duke.edu and log in using the Shibboleth button.
  • Click the Dashboard icon (top left)
  • If there is a tabbed window at right, select the “Groups” tab then click the “New group” button under the tab; if there is not a tabbed window at right, click the New Group button in the dashboard.
  • In group path, using YOUR NetID, put in NetID_classes
  • In the details block, write a note to yourself that this is the group where class pages go
  • Click the Create Group button - this should create the group and then go to the group’s page
  • Click the New project button on the right
  • In the Project path, type EGR103
  • Make sure the Visibility Level is *Private*
  • Click the Create project button
  • Click on Settings at left
  • Click on Members under settings
  • For the next part, you will be adding the instructors and your lab section TAs; their NetIDs will be written on the boards at the front of the room.
    • Click on New project member at right
    • In the people box, add mrg
    • In the Project Access, change to Master
    • Click the Add users box
    • Repeat for the four TAs and for the Head TA

Creating your class directory

Finally, you can go back to your Unix account and set up the Unix version of your directory. Go back into your terminal window and perform the following steps:

  • Change into your home directory
cd ~
  • Clone your new repository - be sure to replace NetID below with your NetID
git clone git@gitlab.oit.duke.edu:NetID_classes/EGR103.git

From this point forward, you should be able to send your most updated version of your files to the repository by going into your EGR103 directory and then typing

git add .
git commit -a -m 'Message'
git push

You should be able to get a copy of your files from the repository, if you really need to, by going into your EGR103 directory and then typing

git pull

You will typically not need the git pull piece as the files on Unix will generally be the most updated. If you lost files, o edited them in a way that you need to recover an older version, git pull will be able to help you there. You must be sure to use the add, commit, and push commands before you log off the system. Not only will that back up your work but it will also put the files in a location where the instructors and TAs can see them to potentially help with coding issues you may be having. Also, sometimes your files will be needed for grading purposes - having the latest and greatest in your repository will make it possible to give you credit for your work.