Github is a powerful, advanced remote Git management tool. You should use this for personal projects as well as team projects.
In this chapter, we are going to learn how to set up Github – an amazing online Git management tool. It allows for individuals or teams to push, pull, merge, and manage their entire code base. You can create public or private repositories (great for companies working on new apps).
In the developer world, a Github profile can be equated with a portfolio of work. Therefore, it is paramount to build out a nice, beefy Github profile with all the projects you build throughout this book; Devslopes courses, or any other personal projects you want to post publicly.
First, open Safari or your browser of choice. Navigate to
www.github.com and create an account by clicking the
Sign Up button at the top of the page.
Create an account and follow the steps necessary to activate your account.
Next up, we need to create an SSH key to identify your computer as a trusted device so that Github knows that all code is coming from a secure device. It works just like a key into a lock, but for your Github account.
On your Mac, go to
Utilities and click on
Alternatively, you can press
Space and type terminal into Spotlight Search to find it. Upon opening, a new Terminal window should pop up.
We need to generate an SSH key for Github to use.
First, type the following but add in your Github email in place of the example email:
$ ssh-keygen -t rsa -b 4096 -C "firstname.lastname@example.org"
Terminal will respond with the following:
Generating public/private rsa key pair.
Then Terminal will display:
Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
Enter to save it to the default locations it chooses.
The next prompt will ask you to create/verify a password to secure the SSH key. This is entirely optional and up to you if you'd like to do so.
Now that we have an SSH key, we need to check if ssh-agent is working and then add it to the SSH agent:
In Terminal, type the following:
$ eval "$(ssh-agent -s)"
Enter and a message should print below similar to this one:
Agent pid 59566
Then type the following command:
$ ssh-add ~/.ssh/id_rsa
Now that we have created a secure SSH key and have added it to our SSH agent, we need to connect it with our Github account so that our Mac and Github can communicate.
In Terminal, type:
$ pbcopy < ~/.ssh/id_rsa.pub
This will copy our SSH key to our clipboard.
Return back to your web browser and click on your profile in the top right corner. In the following drop down menu, click
Settings (Figure 1.15.1).
On the side of the page, click
SSH and GPG keys (Figure 1.15.2).
New SSH key or
Add SSH key to add our key that we have copied (Figure 1.15.3).
Type a descriptive title in the "Title" field (i.e. "Jerry's MacBook Air") and paste in your key to the "Key" field below (Figure 1.15.4).
At the bottom of the page, click the
Add SSH key button (Figure 1.15.5).
You may be required to enter your Github password to confirm making these changes.
After following the steps in this chapter, you are now ready to learn how to use Github. In the next chapter, we will talk about local and remote code repositories and how to push our local code to Github for storage and management.