My First GitHub Project: From a Local Folder to GitHub Using Git and SSH
Introduction
This week I learned how to use Git, Git Bash, GitHub and setting up SSH Keys. Before this, I knew about GitHub but I did not really understand how a project moves from a folder on my computer to GitHub.
A simple way I now understand the relationship is:
Git manages the history of my project while GitHub provides an online home for the project.
In this article, I will explain the steps I followed to create a simple project locally and push it to GitHub.
Creating My Project
I started by creating a folder for my project using Git Bash.
mkdir Kenya-Hospital-Records-Analysis
cd Kenya-Hospital-Records-Analysis
Inside the folder, I created a README.md file and a folder called data.
My project looked like this:
Kenya-Hospital-Records-Analysis/
├── README.md
└── data/
The README.md file is where I can explain what my project is about while the data folder can be used to store datasets.
In the data folder i uploaded an excel file called Kenyan_Hospital_Health_Records
How to use Git
The next step was to make Git start tracking my project. I did this using:
git init
I then used:
git status
This helped me see which files Git was tracking and which files had not yet been added.
To add my files, I used:
git add .
I then saved the changes to Git using a commit:
git commit -m "Initial commit"
One thing I learned is that a commit is like saving a checkpoint of my project. The commit message helps explain what changes I made.
Connecting Git to GitHub while generating SSH Keys
To push my local project to GitHub, I needed a secure way for my computer to communicate with my GitHub account.
I used SSH (Secure Shell).
I first generated an SSH key on my computer and then added the public key to my GitHub account.
An SSH key normally consists of two parts:
Private key – stays securely on my computer.
Public key – can be added to GitHub.
One important lesson was that the private key should never be shared.
After configuring my SSH key, I tested the connection using:
ssh -T git@github.com
A successful authentication confirmed that my computer could communicate securely with GitHub.
Connecting to GitHub Using SSH Keys
I also learned how to connect Git on my computer to my GitHub account using an SSH key.
After creating the SSH key, I added the public key to my GitHub account. I could then test whether the connection was working using:
ssh -T git@github.com
This was interesting because I learned that SSH allows my computer to communicate securely with GitHub without entering my GitHub password every time I push my work.
Pushing My Project to GitHub
After creating a repository on GitHub, I connected my local project to it.
git remote add origin git@github.com:username/Kenya-Hospital-Records-Analysis.git
I then pushed my project to GitHub using:
git push -u origin main
After refreshing my GitHub repository, I could see the files I had created on my computer now appearing on GitHub.
What I Learned
The biggest thing I learned from this exercise is that Git and GitHub are different but work together.
Git helps me track changes to my project on my computer, while GitHub allows me to store and share the project online.
I also now understand the basic Git workflow better:
Create or change files
↓
git add
↓
git commit
↓
git push
↓
GitHub
At first, the commands looked confusing but after using them practically, I started to understand what each command was doing.
Conclusion
This was my first time taking a project from a local folder on my computer and pushing it to GitHub using Git and SSH.
I am still learning Git and GitHub but I can now create a project, track my files, make commits and push my work to GitHub.
Top comments (0)