- Random Access Musings
- Posts
- Tracing Our Steps: A Guide to Git (Part 3)
Tracing Our Steps: A Guide to Git (Part 3)
Applying Rubber to Road

This is a series of posts about using Git. You can read the previous entries at:
🇺🇸 Happy 4th of July! 🇺🇸
Configuring SSH Keys and Cloning Your Repo
So, we've got a new remote repository. But how do we work on this? We'll need a copy of this repo in a local repository first. And since we'll need to talk to Github to get that copy, we need credentials and authentication. Let's ensure that we can securely connect to our remote repository on GitHub. How do we do that? SSH keys.
An SSH key is like a secret handshake between your local machine and GitHub. I'm planning on writing a deep dive into asymmetric keys and Public Key Infrastructure (PKI) but this will suffice as an explanation for now. It assures GitHub that it's really you trying to connect, without having to enter your username and password every time. Rest easy knowing you won't be fat-fingering your password each time you need to make a change!
Here's a quick rundown on how to set this up for Mac and Linux users. For Windows users, the process is a bit different and this comprehensive guide will walk you through each step.
Generate an SSH Key: On your local machine, open up your command line and type
ssh-keygen -t ed25519 -C "[email protected]"
. Hit enter through the prompts and you'll have a new SSH key generated. Whyed25519
you ask? It's the type of key we're generating, and it's considered the most secure as of this writing.Add SSH Key to the ssh-agent: If your system has the ssh-agent running, you'll want to add your new key to it. Start by ensuring the ssh-agent is running with
eval "$(ssh-agent -s)"
and then add your key withssh-add ~/.ssh/id_ed25519
.Add SSH Key to GitHub: Now, we have to give GitHub your public key. Navigate to the folder where you generated your key and open the
id_ed25519.pub
file with a text editor. Copy its contents. Then, go to GitHub, navigate to Settings -> SSH and GPG keys -> New SSH Key, paste your key, give it a title, and hit "Add SSH key".
All right! Take a breather. That was a lot. Now your local machine can chat securely with GitHub without the need for a password each time. You're essentially a cyber-security expert now. Well, better than most, at the very least!
Now that we have the SSH keys configured, we can get our hands on our remote repository. This is where cloning comes in. Cloning is like ordering a replica of your remote repository to be delivered to your local machine. In your terminal, navigate to the folder where you want your project and type git clone [email protected]:YourUsername/YourRepoName.git
. Replace YourUsername
and YourRepoName
with your GitHub username and the name of your repository, respectively.
Once the command finishes, you'll have a copy of your remote repository on your local machine.

Making Changes in Your Local Repository
Now that we have a clone of our remote repository on our local machine, we're ready to make some magic happen. We're going to make changes, watch git track them, and ultimately push them back to our remote repository. It's kind of like writing a letter, you pen your thoughts (make changes), package it up (commit), and then send it off to the recipient (push to the remote repo).
Open your local repository in your code editor: Navigate to the folder where you cloned your repository and open it in your preferred text editor, anything from Notepad++ to VS Code (or vim, nano and emacs if you're courageous).
Modify the README file by adding a new line of text: Open the README.md file in your local repository and make a small change. Let's write something like "This is a test project to learn about git and GitHub." and save your changes
Open the terminal in the directory of your local repository: Next, you need to open your terminal (or command line) and navigate to the directory of your local repository. This is where the magic happens.
Check the status of your repository: Enter
git status
in your terminal. This lets you view the current state of your local repository, revealing any changes that have been made but not yet staged or committed.Stage your changes: To include the changes you've made to the README file in your next commit, type
git add README.md
. Your changes now sit in the 'Staging Area' (more on this in a bit), poised and ready for the next step.Commit your changes: Time to lock in your changes. Type
git commit -m "Added a new line in README"
. The-m
flag is for adding a brief message, which helps you (and anyone else working on the project) understand what each commit does when scanning through the commit history.
The next order of business, coming in the next post, is sharing these changes back to Github. We'll also learn about the Staging Area and what that does for you. Until next time!
Keep learning and keep growing!
Darrell
Reply