Introduction
This article covers my journey from taking a project from my local folder all the way to GitHub using git and SSH. It is a beginner-friendly guide, no prior experience with version control is required.
What are Git, GitHub and SSH?
These are the key players in any project and it is essential we get a better understanding of what they are and how they interact with each other to come up with a project in the net.
1. Git: Your Time Machine for Code
Git is a Version Control System (VCS) that tracks changes in your files over time. We refer to it as a time machine for our code as it allows us to:
- Save snapshots of our projects at different points
- Experiment with new features without breaking our working code
- Collaborate with others without overwriting each other's work
- Revert to previous versions if something goes wrong
2. GitHub: Your Code's Home on the Internet
GitHub is a cloud-based platform that hosts Git repositories. It is the equivalent of a social network for developers where we can:
- Store our code securely on the cloud
- Share our project with the world
- Collaborate with other developers
- Access our code or project remotely from anywhere
3. SSH: Your Secure Connection
SSH (Secure Shell) is a protocol that provides a secure way to connect our local computer to GitHub. It's more of a digital fingerprint that proves it's really you without the hassle of countless authentication procedures.
Understanding the Git Workflow
Before we start pushing code to GitHub, we need to understand the four major stages our files go through when using Git:
1. Working Directory
This is where we do our actual work. When we create, edit or delete files in our project folder, they exist in our working directory. Git sees these changes but hasn't started tracking them yet.
2. Staging Area (Index)
This is the "waiting room" for our changes. When we tell Git which files we want to save, we add them to the staging area. This allows us to be selective about which changes make it into our next commit.
3. Commit
A commit is a permanent snapshot of our staged changes. It's like taking a photo of our project at a specific moment. Each commit has a unique ID and includes a message describing what we changed.
4. Push
This is the final step where we upload our commits from our local machine to GitHub. Once pushed, our code is safely stored in the cloud and accessible to others (or just to you from other devices).
Prerequisites
Before we begin our journey, make sure you have:
- Git installed on your computer (download from Git)
- A GitHub account (sign up at GitHub)
- A terminal or command prompt (Terminal on Mac/Linux, Command Prompt or PowerShell on Windows)
Step-by-Step Guide: From Local Folder to GitHub
Step 1: Initialize Git in Your Local Folder
First, let's tell Git that our folder is special and should be tracked. Open your terminal and navigate to your project folder using the cd (change directory) command:
cd path/to/your/project
Now, initialize a new Git repository:
git init
You should see a message like:Initialized empty Git repository in /path/to/your/project/.git/
We have just created a hidden .git folder that contains everything Git needs to track your project.
Step 2: Check Your Repository Status
Before making any changes, it's good practice to check the status of your repository:
git status
This command will show you which files are untracked (new) or modified. Initially, you'll see all your files listed as "untracked."
Step 3: Add Files to the Staging Area
Now, let's start tracking your files. To add all files in your current directory to the staging area:
git add .
The dot (.) means "everything in the current folder." You can also add specific files:
git add index.html
git add style.css
Run git status again, and you'll see your files in green, labeled as "changes to be committed."
Step 4: Create Your First Commit
Now that your files are staged, let's create a commit:
git commit -m "Initial commit: adding all project files"
The -m flag allows you to add a commit message directly in the command. Always write meaningful commit messages as they'll help you understand the history of your project later.
Step 5: Set Up SSH for GitHub
To connect to GitHub securely without typing credentials each time, we need to set up SSH keys.
Generate an SSH Key
In your terminal, run:
ssh-keygen -t ed25519 -C "your_email@example.com"
GitHub documents Ed25519 for new SSH keys, with RSA available mainly for legacy systems that do not support Ed25519. (GitHub Docs)
Replace the email with the one associated with your GitHub account. You'll be prompted to:
Choose a location to save the key (press Enter for the default)
Enter a passphrase (optional but recommended for extra security)
Add the SSH key to the SSH agent
The SSH agent helps manage your private SSH key and can remember its passphrase during your session. GitHub documents platform-specific agent setup steps. (GitHub Docs)
Start the SSH Agent
For the Windows method documented by GitHub, open: PowerShell as Administrator. To do that:
- Click Start.
- Search: PowerShell
- Right-click PowerShell.
- Choose: Run as administrator
Run:
Get-Service -Name ssh-agent | Set-Service -StartupType Manual
Then:
Start-Service ssh-agent
These are the current commands documented by GitHub for starting the Windows OpenSSH agent. (GitHub Docs)
Add Your Private SSH Key
Now close the Administrator PowerShell window.
Open a normal PowerShell window.
Run:
ssh-add c:/Users/YOUR_USERNAME/.ssh/id_ed25519
Replace:
YOUR_USERNAME with your actual Windows username.
Example:
ssh-add c:/Users/John/.ssh/id_ed25519
If you do not know your Windows username, you can run:
whoami
You may receive something like:
DESKTOP-12345\John
Your username in this example is:
John
If the key has a passphrase, enter it.
GitHub documents this Windows ssh-add path format. (GitHub Docs)
Avoid an SSH Agent Conflict
Windows may have both:
- Windows OpenSSH;
- Git for Windows' bundled SSH.
GitHub notes that this can sometimes result in Git asking for the passphrase even though the key was added to the Windows agent. (GitHub Docs)
To ensure Git uses Windows OpenSSH, run this on git bash:
git config --global core.sshCommand"C:/Windows/System32/OpenSSH/ssh.exe"
You only need to configure this once.
Add the SSH Key to GitHub
- Copy your public key to your clipboard:
cat ~/.ssh/id_ed25519.pub | clip
The public key should now be in your clipboard.
GitHub documents this Windows-compatible form as an alternative that avoids PowerShell's handling of the < operator (GitHub Docs)
If that does not work, display it:
cat ~/.ssh/id_ed25519.pub
You will see one long line similar to:
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA... johnkamau@gmail.com
Copy the entire line.
- Go to GitHub → Settings → SSH and GPG keys
- Click "New SSH Key"
- Paste your public key and give it a descriptive title (like "My Laptop")
- Click "Add SSH Key"
First Connection Warning
On your first connection you may see a message similar to:
The authenticity of host 'github.com' can't be established.
You may also see an Ed25519 fingerprint.
GitHub's current documentation shows its GitHub.com Ed25519 fingerprint as:
SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU
Before accepting a first-time SSH host, compare the fingerprint shown in your terminal with GitHub's published fingerprint.
GitHub instructs users to verify the fingerprint before typing yes.(GitHub Docs)
If it matches, type:
yes
and press Enter.
Successful SSH Connection
If everything is correctly configured, you should get a message similar to:
Hi YOUR_USERNAME! You've successfully authenticated, but GitHub does not provide shell access. This is a success message.
GitHub documents this expected successful response.(GitHub Docs)
Step 6: Create a Repository on GitHub
Now it's time to create your project's home on GitHub:
- Log in to GitHub.com
- Click the "+" icon in the top-right corner and select "New repository"
- Give your repository a name (you can use the same name as your local project)
- Add an optional description
- Choose the repository visibility: Public (everyone can see) or Private (only you and collaborators)
- Don't initialize with README, .gitignore, or license files (we already have our code)
- Click "Create repository"
Step 7: Connect Your Local Repository to GitHub
GitHub will show you instructions for connecting your existing repository. We'll use the SSH option:
git remote add origin git@github.com:yourusername/your-repository-name.git
Replace yourusername with your GitHub username and your-repository-name with your repository name.
This command tells Git that the remote repository (the one on GitHub) should be referred to as "origin."
Step 8: Push Your Code to GitHub
Now for the moment of truth; uploading your code to GitHub:
git push -u origin main
Let's break this down:
-
git push: Upload commits to a remote repository -
-u origin main: Set the upstream branch tomainon theoriginremote - This is a shortcut so you can use
git pushin the future without all the parameters
Step 9: Verify Your Push
Go to your GitHub repository page and refresh. You should see all your files there!
Conclusion
We have just completed our journey from a local folder to GitHub! We have learned the essential Git workflow; from creating commits in your working directory to securely pushing them to GitHub using SSH. This is the foundation of modern software development, opening doors to collaboration, backup, and professional version control.

Top comments (0)