DEV Community

Wanjira Njeri
Wanjira Njeri

Posted on

My First GitHub Project: From a Local Folder to GitHub Using Git and SSH

Introduction

For my first GitHub project, I chose to create a simple Personal Expense Tracker. The idea is to keep my expenses organized and eventually use data analysis to understand where my money goes. The project can contain an Excel file for recording expenses, a Python script for analysis and a README.md file explaining the project.

Opening directories

Open Gitbash and run ssh -T git@github.com to confirm that my Git successfully connected to Github.

Run pwd to confirm my current location.This will show the home directory.
Run ls to list the files and folders in my current directory.
Now move to the desktop by running cd Desktop

Create the Project Folder

The project I am working on is Personal-Expense-Tracker

Start by creating a folder for the project on my computer and navigating into it by running,
mkdir personal-expense-tracker

Move into the folder I created by running,
cd personal-expense-tracker
I now create more folders in my current directory,
mkdir data
mkdir scripts

I then create a file by running README.md where I will explain the content of the entire project.

I could create and add information to the file using the format "echo Personal expense tracker">README.md
I can then check the contents using
cat README.md
If I need to make further changes, I can open the file using
nano README.md

Initialising Git

After preparing my project,I initialise Git inside the project folder.
I do this by running
git init
I then check the repository to see what files Git could detect by running
git status
After confirming that I am working in the correct project folder, I add my project files to the staging area
git add .
The files are now ready to be saved. I creat my first commit with a message describing what I have added
git commit -m "Add personal expense tracker project"

The commit acts as a checkpoint, so I have a record of the project at that particular stage.

Connecting the Project to GitHub Using SSH

The next step is to create an empty repository on GitHub. I then connect my local repository to the GitHub repository using its SSH address
git remote add origin git@github.com:USERNAME/personal-expense-tracker.git

Here origin is simply the name given to the remote GitHub repository. I can check that the connection is successful using
git remote -v

The SSH method allows my local Git repository to communicate with the GitHub repository using the SSH connection configured for my GitHub account.

Finally, I push my project to GitHub
git branch -M main
git push -u origin main

The first push connects my local main branch with the main branch on GitHub. After this, I can normally use just git push for future updates.

Making Future Updates

If I later add new features, such as a Python script that calculates my monthly spending or update my Excel analysis, I don't have to repeat the entire process. I simply follow the normal Git workflow,
git status
git add .
git commit -m "Update expense analysis"
git push

I can check what has changed, stage the changes, commit them as a checkpoint and then push them to GitHub.

Conclusion

This exercise helped me understand that GitHub is not just a place where I upload files. Git allows me to track the development of my project locally while GitHub gives me a remote place to store and share that project. Using Git with SSH gives me a practical way to move a project from my computer to GitHub and continue updating it as I work on it.

Top comments (0)