Difference between revisions of "EGR 103/GIT"
Line 30: | Line 30: | ||
* To see the SSH Key, type: | * To see the SSH Key, type: | ||
cat ~/.ssh/id_rsa.pub | 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''' | + | * To copy the SSH Key to your clipboard, simply select the text starting from '''ssh-rsa''' and ending with '''NetID@machine''' or '''NetID@duke.edu''' |
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: [[File:Git AddKey.PNG]] | 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: [[File:Git AddKey.PNG]] |
Revision as of 13:06, 19 August 2015
Contents
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, to put their work into a repository that is accessible to the TAs and instructors, and to get public files for the course from the instructors. While there is naturally some overhead associated with learning how the program works, understanding git is a valuable skill for people 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, ask 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:
- 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:
- In the Name box, put in your name, followed by your NetID in parenthesis. For example, Dr. G's is
Michael R. Gustafson II (mrg)
- Be sure to include any number that forms a part of your NetID.
- Click on the SSH Keys entry in the menu at the left of the page:
- Click on the Add SSH Key button at the right of the page:
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 or NetID@duke.edu
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:
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 (MobaXterm) 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
You should only ever need to issue the clone and mv commands for this folder once. 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 the EGR103public
directory and pull the files:
cd ~/EGR103public git pull
To make sure your folder is correctly connected to the repository, you can look at your configuration file. Make sure you are in the EGR103public
folder and then type
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 at the 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 - be sure to include the underscore character.
- 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, located directly under settings; the icon looks like a group of people:
- 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.
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
You should only ever need to issue the clone command for this folder once. 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
If, for some reason, you need to retrieve an archive copy of your files, you can do this by going into your EGR103 directory and then typing
git pull
However, you will typically not need the git pull piece as the files on Unix will generally be the most updated. If you lost files, or edited them in a way that you need to recover an older version, git pull will be able to help you there.
General Practices
Whenever you first log in to do work for a new lab, you will want to make sure to get the most updated version of the public files; that process will be in the terminal window:
cd ~/EGR103public git pull
You will then want to set up a folder for that lab in your own EGR103 folder and put your work there:
cd ~/EGR103 mkdir labNN cd labNN
Finally, whenever you are finished working or if you just want to make sure to push any changes up to the repository, you will want to push your entire EGR103 folder up to the Gitlab server:
cd ~/EGR103 git add . git commit -a -m 'Message' git push
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.