What we will cover

Git and GitHub Setup

Introduction

New to using Git and GitHub?? This is the place to start.

We are going to get you up and running using these 2 amazing technologies in no time. By the end of this you should have a fully working Git and GitHub environment to start working with.

What is Git

Git is an open source version controlling software that allows users to track changes to files. It was created by the creator of the Linux kernel Linus Torvalds. It is the most used and popular version controlling software and it is essential for any developer to have and know how to use.

What is GitHub

GitHub is a cloud platform that allows users to store their git repositories, it also is used widely for collaboration between many users on one single code base. GitHub is owned and managed by Microsoft and works wonders with Git. After learning the basics of Git this is the first next step to learn how to use GitHub combined with Git to make magic happen.

Git Setup

First we download and install Git.

Install Git Here. Choose your specific OS, and follow the installation wizard! If you are on windows machine I would recommend installing Git Bash along with Git.

Once Git is installed launch your terminal/cmd and run the following command.

bash\ngit --version\n

This will output the version of the git software you have just installed! If this however gives you and error you will need to add the directory where git was install onto your computer environment variables.

HOORAY GIT IS NOW INSTALLED!!

Now let configure 2 very important global variable in git

So in-order to do this we need to open up our terminal and run the following 2 command

git config --global user.name  "<Your Git Username>"
git config --global user.email "<Your email you will use for github>"

The 2 variable will become important once we start using git and github together. Please make sure that the email address you enter will be the same one you will use to create your github account. These variables can be changed at any time using the same commands.

GitHub Setup

So now we can go to GitHub, and create our GitHub account. Remember to use the email that we used during the Git setup. Once this is completed navigate around the tabs and windows on github to check everything out and see what you can find out. As a developer your ability to tinker and play around with things that are new will truly determine your growth speed.

Next we need to connect our local computer git software to our Github account to allow us to have easy access when sending and retrieving data

SSH key Setup

So what is the SSH key thing that I am mentioning. Well this is something that is widely used in development and it consists of 2 keys, one being a private key and the other a public key. What these keys allow us to do it authenticate our local computer to some server without having to provide username and password. This is a very secure way of authentication so let's get this setup between our local machine and github.

Let's actually see if your local computer doesn't have and generated SSH key already. In the terminal type in the following command.

ls ~/.ssh

If you run this command and you see file with the name id_rsa and id_rsa.pub then you already have SSH key generate. You can skip the next step of generating SSH key then.

First we would need to actually generate these 2 keys I was talking about and the way we can do this is by opening up our terminal (use GitBash if you are on windows or use the new windows terminal powershell) and running the following command.

ssh-keygen -t rsa

This will prompt you with a few questions. Just press enter on all of these questions now need to enter any information.

Once this is complete you will now have generated 2 keys. We can check out these keys by runnig the following command.

# This will log out the public key
cat ~/.ssh/id_rsa.pub

# This will log out the private key
cat ~/.ssh/id_rsa

Now that we have these keys we can take the public key and copy it. Then we will add the public key in our GitHub account. Go to this page in your GitHub account.

Give the SSH key a name, for example my-windows-computer or anything you want and paste in the public key. And now say Add SSH key.\n\nAdd SSH Key To GitHub

Ok so now that that is done we can go to our terminal and test our setup. By running the following command

# Attempt to ssh to GitHub
ssh -T git@github.com

# You will get this prompt just type -> yes
The authenticity of host github.com (IP ADDRESS) cant be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)?

# You should receive the following output telling you your setup was successfully
Hi username! You've successfully authenticated, but GitHub does not provide shell access.

Conclusion

Checkout my Git Basics article where I teach you the basics you need to get going with Git.

😎🙌 Congratulations your are now one setup closer to becoming a bad ass developer