Install git:
sudo apt-get install git-core
.Create an account on GitHub: https://github.com/
Tell git your name and email address. Open up a terminal and type:
git config --global user.name "YOUR FULL NAME"
git config --global user.email "YOUR EMAIL ADDRESS"
If you are worried about email privacy, then use “<username>@users.noreply.github.com” as your email address (where you have replaced <username> with your GitHub username), then follow the instructions here to make your email address private on GitHub.
Choose your favorite editor to be your default
Nano (a simple text editor):
git config --global core.editor "nano -w"
Notepad (Windows only):
git config --global core.editor "c:/Windows/System32/notepad.exe"
Emacs (for the brave) if it is already installed:
git config --global core.editor "emacs"
To integrate GitHub (the website) with git (the command-line program), you have to set up the proper authorization.
If you can already integrate with GitHub through the command line then you can skip the rest of these notes. If you are not sure, then please continue.
GitHub now requires you to use either Personal Access Tokens or SSH Keys for interfacing. For this class, we’ll use SSH Keys since its implementation is slightly easier.
An alternative setup using personal access tokens can be found here.
SSH uses what’s called a key pair where GitHub has a “public key” (a very long publicly known password) and you have on your computer a “private key” (a very long privately known password).
Think about the public key as a padlock, and the private key as the key. You have to use to private key to unlock the public key.
You need to generate a new private key, and go through the below steps, for each computer for which you intend to use git.
R Studio makes it easy to generate a key pair.
Check to see if you already have an SSH key pair by running the following in R
file.exists("~/.ssh/id_rsa.pub")
It will return FALSE
if you do not have a key pair.
Open up Tools > Global Options… > Git/SVN.
If you do not have an SSH key pair, then click on “Create RSA Key…”
Click on “View public key”
Copy the entire text that shows up. This is your public key.
Go to Add Public Key to GitHub to continue authentication setup.
In the terminal run
ls -al ~/.ssh
This will say something like “ls: cannot access ‘/c/Users/Vlad Dracula/.ssh’: No such file or directory” if you don’t have any public/private key pairs.
This will list out files names like “id_rsa.pub”, “id_ecdsa.pub”, or “id_ed25519.pub” if you do have a public/private key pair.
If you do have an SSH key, go to the next section (“Add an SSH key to the ssh-agent”)
If you don’t have an SSH key, follow the below steps.
In the terminal, run
ssh-keygen -t ed25519 -C "your_email@example.com"
Press enter if prompted where to save the key to accept the default location.
At the prompt, type a password that you can remember.
In the terminal, run the following to start the ssh-agent in the background.
eval "$(ssh-agent -s)"
In the terminal, run the following to add your SSH private key to the ssh-agent:
ssh-add ~/.ssh/id_ed25519
Run the following in the terminal to show the contents of “id_ed25519.pub”.
cat ~/.ssh/id_ed25519.pub
Highlight the output using your mouse and copy the contents.
On GitHub, in the upper right corner, click on your profile photo and click on “Settings”
On the left sidebar, click on “SSH and GPG keys”
Click on “New SSH key”
In the title field, choose a descriptive title, like “Personal Laptop”.
Paste your key into the “Key” field.
Click “Add SSH key” and confirm your GitHub password.
Enter the following in the terminal:
ssh -T git@github.com
Type “yes” if prompted to continue connecting.
You are successful if you see something like
Hi dcgerard! You've successfully authenticated, but GitHub does not provide shell access.