In this assignment, you will:
install the main programs we will use in the course
create your own GitHub account and start a “repository” that is available for everyone to see
learn to “commit” and “push” changes on your local computer to your online GitHub repository
Use the following link to download R for your particular computer system: https://cran.r-project.org/
It’s a good idea to install R before installing R-Studio https://www.rstudio.com/products/rstudio/download/#download
Here’s the download page: https://git-scm.com/downloads
If you are on a Windows computer, click the “Windows” button and your download should start automatically. Run the .exe file to install “Git Bash”
If you are on a Mac, click the “Mac” button and the .dmg file should download automatically. This will open in your software center and install.
If you are on Linux, here are the instructions, depending on your version: https://git-scm.com/download/linux
Once you have Git installed, open it up (in Windows this will be a shortcut called “Git Bash”, in Mac or Linux, just open your terminal -that scary command prompt- and it will be working in the background) You will see a simple command line interface that looks something like this:
Navigate to your computer Desktop using the command-line. If you’ve never done this before, here’s a nice introduction: https://computers.tutsplus.com/tutorials/navigating-the-terminal-a-gentle-introduction--mac-3855
Basically, you can enter commands to move into or out of directories and look at what files are present.
Here’s an example output from those first two commands:
ls #this lists files in my current directory
## Assignment_1.html
## Assignment_1.rmd
## setup_git_credential_helper.R
pwd #this tells me what my current directory is
## /home/gzahn/Desktop/GIT_REPOSITORIES/gzahn.github.io/data-course/Repository/Assignments/Assignment_1
The “cd” command requires a bit more. You have to tell it what directory to change to…
Mac and Linux users can probably just type “cd ~/Desktop” and they will instantly be on their Desktop folder Windows file paths are a bit different, but it’s probably something like this:
cd C:\Users\YOUR_NAME\Desktop
Once you’re in your Desktop folder (you can check with “pwd”) copy and paste the following into your terminal:
git clone https://github.com/gzahn/Data_Course.git
This will download a folder onto your computer. It will be found wherever you were when you entered the previous command….so hopefully your Desktop.
If you have it, that means you successfully “cloned” my online repository onto your local computer. This “git clone WHATEVER_WEBSITE_ADDRESS” will be very useful to you in this class. It’s how you will access other materials from my GitHub repositories, including exams!
That takes care of the software installation and course materials. Now, you need to set up your own GitHub account online.
This GitHub account is a way for you to store version-controlled code, data, and even your personal website that you will build by the end of the semester. It’s something that you can put on your CV/Resume to demonstrate coding and data analysis ability. Save your password someplace safe. Don’t give it to anyone, including me.
I made a short video walkthrough of the following steps here: https://youtu.be/M9430_eGttI
See these instructions for setting up 2-factor authentication for RStudio.
Enable two-factor authentication
Use the LastPass or other 2FA App for your phone, give it your phone number as a backup, and save your account recovery codes somewhere very safe (gmail draft message?)
You will need to create a personal access token to use GitHub from the command line
SET YOUR PAT TO NEVER EXPIRE
Copy your token and paste it into a text document. To set it as an “environment variable” enter the following in your command-line terminal, replacing TOKEN with the actual token you received online and YOUR_GITHUB_USERNAME with your username (keep all quotes as-is):
echo 'export GIT_PASSWORD="TOKEN"' >> ~/.bashrc
echo 'export GIT_USERNAME="YOUR_GITHUB_USERNAME"' >> ~/.bashrc
exec bash
You can now type the following to see/copy your command-line GitHub token:
echo $GIT_PASSWORD
Now, make a new file called git_credential_helper.sh
In that plain-text file, paste the following (just 3 lines):
#!/bin/bash
echo username=$GIT_USERNAME
echo password=$GIT_PASSWORD
Save it in your $HOME directory
Final step… In your terminal, run the following line, which will tell git that whenever you are on this computer, to use that file to figure out your username and password:
git config --global credential.helper "/bin/bash ~/git_credential_helper.sh"
If you are using Windows, their recent update means that instead, you should use the following:
git config --global credential.helper manager
In your terminal, navigate to your Desktop with the command-line again
Now clone the github page you created (The one called Data_Course_YOURLASTNAME)
Navigate into this new repository (The one called Data_Course_YOURLASTNAME) and type the following commands in order:
(actually, copy-paste is better than typing. Coders use CTRL-C / CTRL-V more than anything else!)
(What?! It’s not pasting text into your terminal? Ah, use CTRL-SHIFT-V or SHIFT-INS to paste into your terminal!)
echo "This README file contains information about my uploaded assignments" >> README.md
git add README.md
git commit -m "1st commit"
git push
(Here it will ask for your GitHub userID and password....enter those when asked)
This series of commands commits your changes (Adding that text to the README.md file)
and pushes the changes back onto the website version
Check back on your GitHub page online…if you see that new text (“This README file contains information about my uploaded assignments”) then you are finished!
To get credit, upload a link to your GitHub repository to “Assignment 1” in Canvas. I’ll click on that and see whether your README.md file is correct.
You now have a copy of all the current course materials along with your own personal repository This GitHub repository is where you will keep projects you’re working on, notes, examples, data sets, etc.
Warning: I will be cloning all of your repositories onto my own computer to keep track of your course work So don’t write hate mail about me in files in that directory.
The point of this is that this workflow (save, add, commit, push) needs to be muscle memory for you as we progress in the course. Doing it 40 times is much better than 10 times, but 10 is all I am requiring at this point.