Introduction
The following is a step-by-step process of how i was able create my first GitHub project from a local folder and upload it to Github using Git and SSH.
Creating a local folder using git.
Using Gitbash, I wanted to see the list of files and directories on my pc. I used the command function ls which enabled me to see them.
Since I wanted to create a folder in Desktop under OneDrive, I used firstly cd OneDrive which allowed me to access OneDrive then used cd Desktop allowing me to access Desktop. Basically the command function cd (change of directory) allows one to access a directory that is required while Using cd .. allows one to go to the previous directory.
Using mkdir Kenya-Hospital-Health-Records-Project I was able to create a folder under the name Kenya-Hospital-Health-Records-Project. We can use hyphens, underscores and quotes in names that contain more than one word because inclusion of spaces will create separate folders instead of the required one folder.
Using cd Kenya-Hospital-Health-Records-Project to access our folder, I created another folder inside it called data using mkdir data.
Creating a README file
I created Readme file using touch README.md where .md denotes mean Markdown. A Readme file would be able to explain the context of our project on Github and to do this we use the command function echo to print text.
I used echo "# KENYA HEALTH RECORDS ANALYSIS" > README.md to indicate title of the README file and using # to indicate it is as the main title.
Using echo "## Project Overview" >> README.md I was able to mark it as a sub heading. using > instead of >> would have simply replaced our Tittle an used the subtitle as the main tittle hence I used >> to simply add and not replace.
To see the contents we have written so far we use cat README.md.
I also incorporated nano README.md to edit some parts where i saw fit to edit.
Initializing git
Then I used git init which is used to treat the folder as a git repository creating a hidden folder. To see the hidden files the command function ls -la is used.
I used the function git status to see the untracked files (these are files which exist but git hasn't been instructed to add them).
Committing and pushing
I then prepared changes for the next commit by using git add . followed by git status to confirm it is ready for commitment.
git commit -m "add Kenya Hospital Analysis Project" to save changes to the commit. The message in quotes indicates what changes I made.
Then I used git log --oneline to see the commit history.
A side note was the command function git branch -M main which would have been used if the output did not have main to it.
I further ran git remote add origin SSH where the SSH is on Github and its content is copy pasted directly after the origin.
Then used the command git remote -v to confirm the remote URL was added correctly and lastly git push -u origin main to upload it on Github.
Top comments (0)