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.
First Order of Business, Set Up Git
Sorry PC folks, these are mac instructions.
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 4: After you identify yourself, tell Git the email address that will be associated with your GitHub.
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:
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:
Step 2: Generate a new SSH Key
Enter the text and your GitHub email:
“Enter a file in which to save the key” will pop up and just press Enter to continue.
Create a passphrase – it won’t be visible when you type it – then press enter and enter it again:
After you enter a passphrase, review the fingerprint, or id, of your SSH key.
Step 3: Add your key to the SSH agent
Make sure that ssh is enabled:
Add your SSH key to the ssh agent:
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
After you press enter, it will ask you to enter your passphrase to continue.
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:
Contributions by Graham McBain, Dev Evangelist at Galvanize.
Want more web developer tutorials and content? Subscribe to our web development newsletter.