Introduction
When I first heard the words Git and GitHub, I actually thought that git was the short form of GitHub, only to realise that they are two different things.
Git is free, open-source version control software used by programmers to track code changes and collaborate. Git is a version control system that runs on my computer. GitHub, on the other hand, is a cloud-based web platform where computer programmers store, share, and work together on software code.
This article explains how I created a local repository and pushed the project to GitHub using Git and SSH.
What Requirements I Needed
- A GitHub account
- Git installed on the Computer
- An SSH Key configured with GitHub
- Visual Studio Code installed on the Computer
How I Did It
I started by opening GitBash on my desktop, then typed ls to see what my desktop contained.
The ls command means list, and it is used to list the contents of a directory.
Next, I created a folder called My First Project.
using mkdir "My First Project"
mkdirmeans make directory and is used to create a new folder.
I then used cd "My First Project" to enter the folder.
cd means change directory and is used to open folders.
While in the My First Project folder, I created another folder called Data.
Using mkdir Data
Then I created a README file using touch README.md
touch is used to create an empty file
So to add information to the README file I used
echo "# My First Project"> README.md
echo means to output or display text, data, or variable values directly to a screen, terminal, or log file.
The # is used to show that it is a heading.
I then generated practice data and copied it into the Data folder
I then used echo "This is practice data on Hardware sales">> README.md
This time I used >> so that I could not overwrite the first line in the README file.
I then used cat README.md to see the contents of the README file.
cat is a standard command used to read, print, combine, and create text files directly from the terminal.
I then confirmed the contents of the Data folder using ls Data
I keyed in git init
git init stands for "Git Initialize," and it is the command used to create a brand-new, empty Git repository.
Then git status
git status shows the current state of your repository's working directory and staging area. It tells you which files have been changed, which ones are prepared for your next save point (commit), and which ones Git is completely ignoring.
Then ran git add .
git add is the command used to save your code changes into a temporary preparation zone.
Then I ran git commit -m "Add My First Project"
git commit is a save point, or snapshot, of your project's files at a specific moment in time.
I then ran git log
git log is a command-line tool used to view the history of changes (commits) made to a code repository.
Then git remote add origin[SSH link]
The SSH link is found on GitHub, where you copy it from the repository you created.
Then I ran git remote -v
Finally, I ran git push -u origin main
git push uploads your local repository commits to a remote repository.
After this, the project was uploaded to my GitHub.
Conclusion
I was able to learn about the difference between git and GitHub, and along the way I managed to understand the process of pushing a project from a local repository to an online repository using Git, GitHub, and SSH.
Top comments (0)