Introduction
Starting my journey into data science and analytics has introduced me to many new tools and concepts. One of the first things that we have learnt so far is Git and Github.
At first, it seemed so difficult and confusing. But after being taken through the process and researching on my own I realized that the basic workflow is very straightforward.
In this article I’ll share my experience on how I took a project from a local folder on my computer and pushed it to GitHub using Git and SSH.
What is Git and GitHub
Git is a version control system which runs on your computer and keeps track of changes made to your project. It also allows you to keep a history of the changes made and is usually installed on your local computer.
GitHub is an online service where Git repositories are stored. It stores your repository online and makes it possible to share and collaborate on projects.
Repository is a project being tracked by Git.
Requirements Needed
- Create a GitHub Account
- Install Git on your local computer then:
- Configure Git username and email
- Generate SSH Key
- Add SSH public Key to GitHub
- Test GitHub SSH Authentication
Step 1: Creating A Local Project Folder
I started by opening GitBash on my laptop and then followed the following steps:
• I ran ls to show a detailed list of the files and folders inside my directory.
• I then ran cd desktop to move into the desktop folder.
cd means change directory
• I ran pwd to check the folder I was currently working in to ensure that it was desktop.
pwd means print working directory
Our project was called Kenyan-Hospital-Health-Records, so I followed the following steps to create a folder.
•I ran mkdir Kenyan-Hospital-Health-Records-Analysis to create a folder. mkdir means make directory and is used to create a new folder
• I then ran cd Kenyan-Hospital-Health-Records-Analysis to move into the new folder. cd means change directory and is used to move from one folder to another.
• I then ran mkdir Data to create a folder under the Kenya-Hospital-Health-Records-Analysis folder.
• I also ran touch README.md to create a README file. README explains the entire project i.e. what the project entails, the data set used, tools used, what each folder contains and important findings.
Step 2: Copying The File From Downloads To The Folder
The data was shared through WhatsApp, so I downloaded the file and copied it to the project folder that I had created. To copy the data from downloads to the project folder I used the below command in gitbash.
Cp ~/Downloads/Kenyan_Hospital_Health_Records.xlsx ~/desktop/Kenyan_Hospital_Health_Records/data.
Step 3. Adding and Displaying Text On README.md
To add text to the README file I used the command echo “# Kenyan Hospital Health Records Analysis”> README.md
echo means print text, #is a markdown syntax for a heading and > redirects the text into a file.
Then I ran the command echo “##Project Overview”>>README.md. I used >> to avoid replacing the existing files content.
I then ran cat README.md to display the contents of the README file. Cat displays the raw contents of the file and README.md is the markdown file you are asking to view.
To confirm the contents of the data folder, I ran the ls Data command.
Step 4. Connecting Local Folder and GitHub Repository
After creating my folder, I ran the git init command to initialize the Kenyan Hospital Health Records Analysis directory as a repository. git init is used to turn a normal local folder into a git repository. Git then creates a hidden. git directory, which is used to track changes and store the repository's history.
To check the hidden directory, I ran the ls -la command.
Next, I checked the status of my repository by running the command git status. It helps me understand what is happening in my repository by showing me what files git is tracking, which files have been modified and which files are untracked.
Then I ran the git add. command. This command is used to stage files and changes so they can be included in the next commit.
Finally, I ran the git commit -m “ Add Kenyan-Hospital-Health-Records-Analysis”command. A commitis a snapshot of the changes that you want Git to remember and -mallows you to add a message describing the commit.
The next step was linking the local folder to the repository. This involved the following steps:
•I logged into my github account and created a new repository. Gave my repository a name, description and then created the repository.
•I then copied the SSH Key from github and used it to link my local repository to the Github repository by running the command: git remote add origin git@github.com: my username/ Kenyan-Health-Records-Analysis.git
•To confirm the connection, I ran the command git remove -v
•To push my project to Github I ran the command git branch -M main to make sure my main branch is called main.
•Then finally I ran git push -u origin main to push my project to github.
Conclusion
This project has taught me the difference between Git and GitHub. It has also taught me that GitHub isn’t just a place to upload files. It allows me to track my work,manage different versions of my project and build a portfolio that I can share with other people. I have learnt that it is okay not to understand everything immediately. This is my first project and there is still so much to learn about Git and GitHub but it is a very important step in my journey into data science and analytics.
Top comments (0)