DEV Community

Cover image for Kickstart Your GitHub Journey With These Easy Steps
berack kaunda
berack kaunda

Posted on

Kickstart Your GitHub Journey With These Easy Steps

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:

  1. Very basic knowledge of Git
  2. Git installed in your system
  3. 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
Enter fullscreen mode Exit fullscreen mode

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 .
Enter fullscreen mode Exit fullscreen mode

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"
Enter fullscreen mode Exit fullscreen mode

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.
Image description
Follow the instructions and Create Repository.
Image description
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.

Image description

git remote add origin <link>
git branch -M main
git push -u origin main
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Replace the message with a descriptive of your own.

Happy Coding!!!!!

Top comments (0)