You will be using Github individually and collaboratively. We will set up your development environment to be able to communicate with your Github account. You'll be able to clone code from a remote repo using SSH and make changes to it on your computer.
Table of Contents:
- Create a Github Account
- Configuring Github with your Terminal
- Create a Repository on Github
- Name your repository
- Add SSH Key
- Clone Using SSH
Create a free Github Account. Remember the email and username that you enter. If you already have one, you can skip to the next step.
-
In your Terminal application (the folder you're in doesn't matter), we first want to ensure that you can use the
git
tool for the next few steps.- Start by running the command
git -v
which will print the current version of thegit
tool on your computer. - If you are using a Mac and this is your first time, a popup called Install Command Line Developer Tools will appear. Follow the instructions to install on your computer.
- Start by running the command
-
Once this is done, in your Terminal, run the following lines. Be sure to replace
Your Name
andYour Github Email Address
with your actual Github login information:
git config --global user.name "Your Name"
git config --global user.email "Your Github Email Address"
git config --global credential.helper store
- Confirm that the configuration was successful by running
git config --global user.name
. The terminal should print out your name. Next, rungit config --global user.email
. The terminal should print our your email address.
- Navigate to Github in the browser and log in. ON the left, click the button to create a new repository.
Name your repository my-first-repo
. Choose to add a README.md file. Create the repository.
While we're configuring GitHub, we should add a new SSH key to allow you to push and pull from Github using SSH.
-
First, check if you already have an SSH key by running
ls ~/.ssh
. If the terminal prints out a file(s) that look likeid_ed25519.pub
then you already have a key. -
If the running previous step printed "No such file or directory", then run
ssh-keygen -t ed25519
to create a key.- It will ask you to enter a file to save the key, leave it blank and press enter. It will say that it created the directory
/Users/<your_username>/.ssh
- It will ask you to enter a passphrase, leave it blank and press enter twice to confirm.
- If you've done every correctly, you should be something like this printed to your terminal:
- It will ask you to enter a file to save the key, leave it blank and press enter. It will say that it created the directory
Run cat ~/.ssh/ed25519.pub
in your terminal. Copy the output (starting from ssh-ed25519
and ending in .local
). You'll need it for the next step
- Navigate to the homepage of Github in your browser. Go to your account settings:
Click "SSH and GPG Keys":
Click the "New SSH key" button:
Put a description title about what environment the SSH key is associated to. For example, if you are setting up a Marcy Macbook, name it something like "Marcy Macbook", or if it's your personal laptop you can name it "Personal Marcy Computer". Open the 'Key type' dropdown and select 'Authentication Key'. Paste the key in the text area and click "Add SSH key".
- Go back to your repository on Github. Then, click on the Code button and make sure the pop-up has "SSH" underlined and selected. The url should start with
git@github.com:...
. If this is not the case, click the link that saySSH
. Copy that URL in the text box.
-
Back in your code editor's terminal, make sure that you have a
Unit-0
folder and that your "working directory" is yourUnit-0
folder. If not,cd Unit-0
to jump into it. Clone down the project usinggit clone repo_ssh_url
, replacingrepo_ssh_url
with the URL you copied from the previous step. If asked, "Are you sure you want to continue connecting", typeyes
. -
Then change directory into your project
cd my-first-repo
or whatever you named your repository. -
Once your repo can been cloned down, use the vsCode IDE to update the
README.md
inside of yourmy-first-repo
project. This is not to be confused with theREADME.md
in the root folder of your environment. You should specifically open and edit the one in yourmy-first-repo
folder. Add a 3-4 sentence bio about yourself. Be sure to save the file. -
Push the changes back up to Github using best practices. In the terminal, run:
git status
git add README.md
git commit -m "added bio"
git push
- Go back to Github to view your repository in the browser. Refresh the page and confirm that you see your newly added bio!
Once you have completed all the steps in these instructions, reach out to a technical instructor to verify you are finished.