Introduction
This article is a walk through of my first project where I pushed a local folder containing health data to Github using Git and SSH.
Tools used
- Github - This is an online service where you can store Git repositories and it makes it possible to share and collaborate on projects.
- Git - This is a version control system that runs on your computer and keeps track of changes made to your project.
- SSH (secure shell) - We use SSH when your computer needs a secure way to prove to Github that it is authorized to access your Github account and its repositories.
On windows
Open Gitbash and check your current location
Run
pwd
Which stands for print working directory
running pwd asks which folder am I currently inside?
List files and folders around you
Run
ls
Which shows the files and folders inside your current directory
Move to the Desktop
I created my project on the Desktop by running
cd Desktop
Where cd means Change Directory
Create the project folder
I named my project
kenya-health-records and run
mkdir kenya-health-records
Where mkdir means Make Directory or create new folder
To confirm that the folder exists
run
ls and you should see kenya-health-records
Enter the project folder
Run
cd kenya-health-records
Then verify the project by running
pwd
Create a proper project structure
Here I created three project folders by running
mkdir data
mkdir notebooks
mkdir scripts
Then I created the README by running
touch README.md
Which explains the entire project
Adding the existing hospital dataset
Since the hospital dataset was already on my computer under Downloads
I copied the dataset directly from downloads to the data folder I had created inside the project.
To verify the dataset was copied I run
ls data
And the outcome was kenya_health_records.csv
Adding content to the README.md
Since the README.md explains the project to anyone who opens the Github repository.
I started with echo "#kenya hospital records" >README.md
where
-
echomeans print text - # is a Markdown syntax for a large heading
- > Redirects the text into a file in this case to README.md
Then I added the project overview, tools used, and project challenges.
To check my README I run
cat README.md
Which displayed the contents in the README including the tittle, project overview, tools used and project challenges.
Initializing the project with Git
Run
git init
Where git init means initialize this directory as a Git repository.
To check the project status
Run
git status
Where this command is asking Git what is happening to the project.
Because this was a new repository Git showed the files as untracked
Then run
git add
Which stages the project from the current directory
Then check
git status again
Create the first commit
Run
git commit -m "Add kenya hospital project"
where
-
git commit- creates a saved Git checkpoint. - -m - means message.
- "Add kenya hospital project" is the commit message that explains what was saved.
Short commit history
To get a shorter project history
Run
git log --online
Check the current branch
Run
git branch
which returns
*master
rename it by running
git branch -M main
then run git branch and it changed to *main
Create Github repository
Open Github on browser and create a new repository and name it as kenya health project and add a brief description of the repository and choose it s a public repository and create the repository.
After creating the repository Github displays connection options
select SSH and git hub will givean adress which is git@github.com:karianjahi8/kenya-health-records.git
Conecting the local project to Github
Return to the gitbash terminal then run
git remote add origin git@github.com:karianjahi8/kenya-health-records.git
Where
- remote is another Git repository your local repository can communicate with.
- add is a new remote connection.
- origin is the conventional nickname for the main remote repository.
Push the prioject on Github
Run
git push -u origin main
Where
- git push sends committed changes from my computer to the remote repository.
- -u sets an upstream relationship
- origin The nickname of the Github repository
- main The branch being uploaded
Verify project on github
Return to your github browser and refresh the page and you will see your project listed.
Conclusion
Getting a project onto GitHub for the first time involves two separate concerns Git, which tracks your project's history locally, and SSH, which securely proves your identity to GitHub so it'll accept your pushes.
Top comments (0)