DEV Community

Mercy Siele
Mercy Siele

Posted on

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

Introdction

I always knew that GitHub is where developers keep and share their projects but I have always wondered how developers get the projects from their computers onto GitHub.When I started learning Git aeverything started falling into place. I recently worked on my first GitHub project using Git, Git bash, GitHub and SSH key.
Before I explain what I did, I first wanted to understand what each of these terms mean.

Key Terms

- Git
It is a software tool that tracks changes locally in your computer.
- GitHub
It is an online platform where repositories are posted online for collaboration.
- SSH Key
This is a secure digital credential that is used to connect the local Git software to the online GitHub account without typing a password everytime.
- Git Bash
This is a program used to interact with Git using commands

Setting Up My Project Folder

I started by creating a folder for my project on the Computer.My project was called Kenya-Hospitals-Records-Analysis.

Creating project folder

I used mkdircommand to create the folder.This is a command used to create a new folder.
mkdir Kenya-Hospitals-Records-Analysis

Moving into the Project Folder.

I used the cd command to move to the project folder.
The cd Kenya-Hospitals-Records-Analysis allowed me to move into the folder itself.

Creating Files and Folders

I created another folder inside Kenya-Hospitals-Records-Analysis using command:
mkdir Data
and a file using command:
touch README.md
The touchcommand is used to create a new file.
I used README.md file to document my project.
The Datafolder contained my project data.

Checking Folders

After creating folders and files, I used lscommand to check what was inside my project folder. The command listed Data folder and README.md file confirming that they had been successfully created.

Initializing Git

I initialized Git using git init command. This created a hidden folder inside my project folder which initialized a new Git repository.

Stagging And Commiting My Files

After initializing my project as a Git repository, I first checked the status of my project to know the files that were not being tracked using git status.
I then used git add .command to add all the files in my project to the staging area for commit.
After staging my files, I used :
git commit -m"First commit" . The git commit -m command saves the staged changes in my local git repository.
I used "First commit" as the commit message because it was the first time saving the project as a git.

Connecting My local Repository to GitHub

After making the first commit, I used git branch to check on the branch I was working on. The branch I was working on was the main branch.
Before starting the project, I had already set up an SSH key and added the public key to my GitHub. The SSH key allowed my computer to securely authenticate with Github when working with my remote repository.
I then connected my local repository with the GitHb repository using the command git remote add origin git@github.com:username/Kenya-Hospitals-Records-Analysis.git.
The origin being the name given to GitHub remote repository.
I then checked the connection using git remote -v which displayed the GitHub repository where my local repository was connected to. Once the connection was done, I used the command git push -u origin main. This command pushes the committed changes on my local repository to GitHub.

Verifying My Project On GitHub

Finally, I opened my GitHub to verify that my project had been uploaded.The Data and README.mdwere displayed verifying that I had successfuly uploaded my project.

Conclusion

This practical experience gave me the foundation on how to use Git,GitHub,Git bash and SSH key.I learnt how to create a local project,initialize it as a local repository,commit changes,connect it to GitHub and push the project to GitHub using SSH key.What seemed like complicated process became easier to understand once I learnt the use of the commands and the different stages in the process.

Top comments (0)