Programming 101: How to Use Git in the Terminal

Now that you know how to access the terminal and command line, you are ready to add another tool to your programming bucket. Being the GitHub master that you are, let’s talk about accessing and using Git in the terminal.

At the heart of GitHub is an open source version control system (VCS) called Git. Git is responsible for everything GitHub-related that happens locally on your computer. The command line can be used to run all Git commands.

Get a GitHub account before you start anything else here. Learn more about why you should be using Github here.

First Order of Business, Set Up Git

Sorry PC folks, these are mac instructions.

Step 1: Download to latest version of Git. If for some reason the file will not open after downloading, download Homebrew and follow directions on the page.

Step 2: Open the Terminal (Open Finder > Applications > Utilities > Terminal)

Step 3: Once the Terminal is open, tell Git “your GitHub name”. You can enter your information after the $.

Step 3 - setting up git

Step 4: After you identify yourself, tell Git the email address that will be associated with your GitHub.

Step 4 - Setting up Git

Generate SSH Keys and Authenticate GitHub

Step 1: Check for SSH Keys in the terminal by entering this piece of text, it will list (ls) the files in your .ssh directory if they exist:

Step 1 - SSH

Check the directory listing to see if you already have a public SSH key. By default, the filenames of the public keys are one of the following:

> id_dsa.pub

> id_ecdsa.pub

> id_ed25519.pub

> id_rsa.pub

Step 2: Generate a new SSH Key

Enter the text and your GitHub email:

Step 2 - SSH

“Enter a file in which to save the key” will pop up and just press Enter to continue.

Step 2,2 - SSH

Create a passphrase – it won’t be visible when you type it – then press enter and enter it again:

Step 2, 3

After you enter a passphrase, review the fingerprint, or id, of your SSH key.

Step 2, 4

Step 3: Add your key to the SSH agent

Make sure that ssh is enabled:

Step 3 - eval

Add your SSH key to the ssh agent:

Step 3 - SSH

Step 4: Add your SSH key to your GitHub account

Go to your GitHub profile:

Click on Settings > SSH Keys > Add SSH Key

In the Title field, add a descriptive label for the new key. For example, if you’re using a personal Mac, you might call this key “Personal MacBook Air”.

Paste your key into the “Key” field then click Add Key.

Confirm the action by entering your GitHub password.

Step 5: Test Your Connection

step 5, ssh

After you press enter, it will ask you to enter your passphrase to continue.

step 5

If it says your username, then it’s time to grab a beer and celebrate! You have officially set up your SSH key and ready to use Git in the terminal. Now that you are ready for endless exploration in the terminal, here are some common Git commands:

Git Commands

Contributions by Graham McBain, Dev Evangelist at Galvanize. 

Want more web developer tutorials and content? Subscribe to our web development newsletter.



By submitting your information below, you agree to our Terms of Use and Privacy Policy.

Need assistance with this form?