What is GitHub?
GitHub is a we-based platform used for project version control and code hosting.
GitHub uses Git, a widely-used version control system.
GitLab and Bitbucket are also similar tools.
Requirements
Before we start the tutorial here are some of the prerequisites:
- Very basic knowledge of Git
- Git installed in your system
- A GitHub account
With a ready GitHub account, we can now begin.
Getting Started
To keep things really simple, you can use one of your projects, if none you can create a simple HTML page.
For the rest of the tutorial, we will be using the Terminal to run commands.
To kickstart, in the terminal navigate to your project root directory.
Initialize Git
In order to store our locally created file/folder to GitHub, the first step is to initialize Git.
Run:
git init
Running this command turns your directory into a new Git Repository.
Addition of Files
This process is known as staging
In staging we mark the repository so that we can track any changes made to our local folder since the last commit.
Run:
git add .
All the files in the repository will be marked, ignoring the .gitignore
file.
Committing files
We are now ready for our first commit on our already marked files.
A commit is a snapshot of the current state of the files, it will prepare the tracked changes for pushing to GitHub.
Run:
git commit -m "Add any message"
The commit message is just a friendly reminder about what changes are in the commit.
Pushing to GitHub
There are two parts of this process.
First and foremost we need to create a repository, here is where we push our local commits to the remote repository.
The last part is pushing our project
Create your first repository
Log into your GitHub account, at the top right corner, click the plus sign icon then select New Repository.
Follow the instructions and Create Repository.
Take note of the created repository name.
Stay on the Create Repository page to finish the next step*.*
Pushing your project to GitHub
On the Create Repository page, navigate to "push an existing repository from the command line" section, copy the three commands provided and paste them in your terminal, press enter to execute them.
git remote add origin <link>
git branch -M main
git push -u origin main
After running these commands, you can reload the browser page to see the changes.
Your project is now listed in the online repository.
If this is your first one, congratulations! You have reached a programming milestone.
Making Updates to the Repository
You can make updates to the online repository by running the following commands.
git add .
git commit -m "Commit message"
git push -u
Replace the message with a descriptive of your own.
Happy Coding!!!!!
Top comments (0)