I thought that when i join Lux Dev i would jump straight into building complex data pipelines and getting to understand kafka, kafka sounds like a really cool name, but if there's one thing I'm realizing quickly, it's that before you can orchestrate complex data pipelines or deploy web scrapers, you have to master the absolute basics of version control.
This week, I was working on setting up a new local project, a health records analysis and pushing it to GitHub entirely through the command line.
If you're just starting out with version control, here is exactly how I took a project from a completely blank folder on my desktop to a live repository on GitHub, including testing SSH keys.
Setting Up the Local Project
First, I needed a place for my project to live. I opened my bash terminal, navigated to my Desktop using he cdcommand, and created the main project folder along with a sub-folder for the data named Data.
cd Desktop
mkdir -p Kenya_Hospital_Health_Records_Project/Data
cd Kenya_Hospital_Health_Records_Project
With the directories created, I copied and pasted my Kenya_Hospital_Health_Records_Project.csv data set we were given in class into the Data folder.
Writing the README via Terminal
Instead of opening a text editor, I decided to build out my README.md right from the command line using echo command. The >operator adds new text the file, while >> adds text to the already creaed line.
echo "# KENYA HEALTH RECORDS ANALYSIS" > README.md
echo "## Project Overview" >> README.md
echo "This project analyses health records of a hospital" >> README.md
I also added a quick list of tools and challenges using the same method and used the cat README.md command to print the contents of the file directly in the terminal to confirm that everything looked right.
Initializing and Staging
Now it was time to turned this folder into a tracked Git repository.
git init
Running git status showed that my Data/ folder and README.md were untracked. To stage them for my first commit, I used add command tell Git to add everything in the current directory:
git add .
Committing the Code
With the files staged, I wrote a commit message to remind myself in future what the code was about.
git commit -m "Kenye Hospital Data Project"
Connecting to GitHub and Testing SSH
At this point, I needed to link my local repo to the empty GitHub repository I had just created.
git remote add origin https://github.com/dev-elvismuoka/Git-Commands-Class.git
I confirmed that the SSH for secure authentication was working before trying to push:
ssh -T git@github.com
The response was: Hi dev-elvismuoka! You've successfully authenticated, but GitHub does not provide shell access.
The Final Push
Finally, it was time for me to push my local main branch to the origin remote on GitHub. The -u command to make sure that for future updates, I can just type git push without typing out the branch name every time.
git push -u origin main
And just like that, the project was live.
Top comments (0)