INTRODUCTION
This a step by step tutorial on how to push a project from a local folder to GitHub using Git and SSH.
Prerequisites
GitHub Account to host the repository
GitBash:
-Used this as my terminal.
-It comes bundled with Git on Windows.
-To confirm installation ran: git --version

A file(s) in the local folder
Verify Git configuration
- First, I verified that the username and email configured for Git are accurate.
The commands:
git config --global user.name- this displays the configured Git usernamegit config --global user.email- this displays the configured email.
-This shows the correct username and email.
Generate SSH key
To generate the SSH key ran the following command:
ssh-keygen -t ed25519 -C "my email"
- The SSH key is saved to a specific file location such as drive C on the laptop. Why use SSH key? SSH is a secure way of authenticating my computer with my GitHub account. Rather than entering my GitHub credentials every time I push files from a local repo to a remote repo, Git uses the SSH key to verify my GitHub account.
Copy the public key
The command:
cat ~/.ssh/id_ed25519.pub
Add the SSH key to GitHub
Login into GitHub
On GitHub click on Profile-Settings-Access-SSH and GPG key- New SSH key
Then:
- Add Title, Key type(Authentication key) and Paste the entire SSH key, Click Add SSH key.
Test SSH key Connection
On Git Bash ran:
ssh -T git@github.com
-This shows the SSH key is successfully authenticated.
Create the Project Folder
-
cd DesktopNavigate to desktop as this is where i would like to save my project folder.
mkdir "Kenyan Health Records Analysis"
- Create the project folder on desktop. This is the folder in which the dataset will be uploaded.
Create the README file and data folder
-
cd Kenyan Health Records Analysis- navigate into the project folder. To ensure the README file, data folder and dataset are uploaded into the folder. -
touch README.md- create a README file -
mkdir data- create this folder within the Kenyan Health Records Analysis folder
-This shows that README.md file and data folder have been created and added successfully into the project folder "Kenyan Health Records Analysis"
Add the CSV file into the data folder
- Copy the csv file into the data folder.
This shows that the dataset is inside the data folder
Edit the README file
-
nano README.md- This command opens the README.md file in the Nano text editor where a user can add or edit its contents. Also, if the file did not exist, it will be created when saved.
- This shows the nano text editor
- To save and exit the text editor:
- Ctrl+O
- Press Enter
- Ctrl+X
Initialize Git
-
git init- initialize a Git repository
Check file status
-
git status- shows the current status of the files
This shows that the current README.md file and data folder are untracked.
Untracked files means that their changes are not being tracked yet.
Stage the files
-
git add .- stage all files/ changes for the next commit -
git status- this shows the README.md file and data folder
This shows that the files are staged and ready to be committed.
Commit the files
-
git commit -m "First commit on health records"- commits all files created to the repo.

-This shows the files have been successfully committed.
Ensure the branch is main
git branch -M main- switch to branch main

- This confirms the branch is main
Create the repo on GitHub
Login into GitHub
Click on Profile icon- Repositories- new Repository
Then:
Choose Owner
Add the Repository name
Add a short description of the project
For the configuration settings choose Public/Private and don't click on add README file
Click Create Repository

This shows the General and configuration settings for the creation of a new GitHub repository.
Copy the SSH link
On the page of the new repo copy the SSH link
On GitBash ran:
-
git remote add origin "git@github.com:Thuita24/Kenyan-Health-Records-Analysis.git"- This commands connects the local repo to the repo on GitHub -
git remote -v- This confirms that the connection was successful.
This shows that the local repo has been successfully connected to the repo on GitHub
Push the files into GitHub
-
git push -u origin main- pushes all files into the repo

This shows that all files have been successfully pushed to GitHub
Basically the workflow is
git init - git status - git add . - git status - git commit - git branch -M main - create GitHub repo - copy SSH Link - git remote add origin - git push
Troubleshooting
When creating the README file, I did it in the data folder instead of the project folder. To move the folder I ran the following commands:
cd ..- to navigate from the project folder from data folder (Kenyan Health Records Analysis)
mv data/README.md .
- this moved the file into the project folder from the data folder.
When creating the folder Kenyan Health Records Analysis i ended up creating three different folders as I did not add quotation marks "" to the command mkdir Kenyan Health Records Analysis
- This shows the three folders that were created
Corrected this by adding quotation marks to the command
mkdir "Kenyan Health Records Analysis"

- This shows the correct project folder created
Challenges Faced
My biggest challenge was understanding how the command git remote worked. I did not fully understand why it was necessary yet all the files in my local repo were staged and committed. Through this project , I learnt that the local repo and GitHub repo are treated as two different repositories by Git. The command git remote add origin is what creates a link between the two repositories.
Another challenged I faced was understanding the importance of quotation marks and spaces when writing commands on GitHub. An example is when I ran mkdir Kenyan Health Records Analysis, Git Bash interpreted each word as a separate folder name instead of one. By adding quotation marks GitBash finally interpreted it as one folder name.
Conclusion
This was an interesting project where I finally understood how git commands such git init, git status, git add, git commit, git remote and git push worked rather than just memorizing them and not knowing what was happening in the background. Additionally, I was learn how create an SSH key and use it to push files to GitHub instead of using HTTPS.
In conclusion through this project I was able to gain knowledge on Git and GitHub basics using SSH authentication.
https://github.com/Thuita24/Kenyan-Health-Records-Analysis.git










Top comments (1)
Elaborate.