DEV Community

Cover image for My First GitHub Project: From a Local Folder to GitHub Using Git and SSH
Leonard Mwilu
Leonard Mwilu

Posted on

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

Introduction

In my 2nd Week in Data Science & AI Analytics at LUX Academy we dive more into Git Bash and GitHub interactions and operations by doing our first project and publishing it on GitHub using push , commit and remote origin commands.

Steps from start to publishing on GitHub

  • Gathering Information

    The data for this project was provided as Excel forms both .xlsx and .csv files, by the instructor.

  • Creation of local folders

    I created my local folder in my laptop's Desktop folder using git bash commands. In Git Bash, using the cd command I navigated to my Desktop which was located inside OneDrive folder. cd ~/OneDrive/Desktop/
    Inside the Desktop folder, I created a new folder and named it after my project Kenya-Hospital-Health-Records-Analysis using the mkdir command.
    I then used cd Kenya-Hospital-Health-Records-Analysis to move into the new folder(directory). Inside this folder, I created a new subfolder called data using cd data, to hold my files. I then created the README file which holds information about my project and is a crucial part of any GitHub repository. Here I used the touch command i.e touch README.md.

  • Moving files from Downloads to my project data folder

    Since the data I was provided with was shared via WhatsApp, I downloaded the files into my laptop's Downloads folder and I had to move them to my project folder(data).
    Using git bash commands I easily moved my file from Downloads to data folder. Command for moving files in git is mv /sourceFolder/filename.file_extension /destinationFolder. In my case all i did to do was

mv ~/Downloads/Kenyan_Hospital_Health_Records.xlsx ~/OneDrive/Desktop/Kenya-Hospital-Health-Records-Analysis/data
Enter fullscreen mode Exit fullscreen mode

Now that my folder and data were set, I was ready to push and publish on GitHub.

  • Creation of GitHub Repository

    In order to push from my local folder to GitHub, I needed to create a repository on my GitHub account. I logged into my GitHub account, navigated to Repositories(appears once you click the profile icon at top right corner) and then clicked NEW. I then type my repository name Kenya Hospital Health Records Analysis, entered a short description about it, and then clicked Create repository. Once my repository was ready I copied the SSH address.

  • Connecting Local folder and GitHub repository

    • First I used ssh -T git@github.com to test my connection which was successful.
    • Using git init I created the hidden .git folder that lets git to track the files in my working directory(folder).
    • Using git branch -M main I ensured that my local branch was named main to align with GitHub defaults.
    • using git add . and git commit -m "adding my kenya health records analysis project" I added my files to the staging area and created my baseline snapshot.
    • I then linked my local repository with GitHub repository via SSH using git remote add <SSH_address copied from GitHub earlier>
  • Pushing my project to GitHub

    Using git push -u origin main I uploaded my commits and set the default upstream tracking branch.

  • Verifying Successful Push

    I then returned to my GitHub account, and after refreshing the page, my project had successfully been uploaded to my GitHub repository and the content of my README.md was on display.

_ I am so happy that after a few challenges with git bash commands I successfully managed to complete my first project. I am ready for the next challenge as we dive deep into Data Science_

Top comments (0)