Git and GitHub: A Beginner's Guide

Published: (January 16, 2026 at 07:56 PM EST)
4 min read
Source: Dev.to

Source: Dev.to

Cover image for Git and GitHub: A Beginner's Guide

Ngigi Nyawira

What is Git?

Git is a free, open‑source version‑control system that tracks every change you make to your files. Think of it as a “save system” that lets you keep multiple versions of your project.

Version control and its importance

Also known as source control or revision control, it is a system for tracking and managing files (especially code) over time.

Why is it essential?

  • Safety net – Quickly roll back to a prior functional version if you make a mistake.
  • Collaboration – Several people can work on the same files simultaneously; the system merges their modifications.
  • Traceability – Every change is recorded with a timestamp, description, and author.
  • Experimentation – Test new features without affecting the main project by creating a branch. If the branch succeeds, merge it; otherwise, discard it.

How to push code to GitHub

Step 1 – Create a local repository

Create a local repository

git init

Check the status of the files you want to push:

git status

Files that are not yet tracked appear in red.

Git status (untracked files)

Add all files to the staging area:

git add .

Verify that the files are now staged (they appear in green):

git status

Git status (staged files)

Commit the changes locally:

git commit -m "Project added"

Git commit output

Step 2 – Connect to the remote GitHub repository

Create a new repository on GitHub, copy its URL, then run:

git remote add origin <repository‑URL>

Step 3 – Push the code

git push origin master

You’ll be prompted to sign in to your GitHub account if you haven’t authenticated already.

Push confirmation

Below is an example of the files as they appear on GitHub:

GitHub repository view

How to pull code from GitHub

Step 1 – Clone the repository

Navigate to the repository on GitHub, copy the HTTPS (or SSH) link, then run:

git clone <repository‑URL>

Clone repository

All commands above assume you are using a terminal (Git Bash, PowerShell, macOS Terminal, etc.) and that Git is already installed on your machine.

Step 1 – Open the Project Folder

cd Git-Assignment

Step 2 – Create a New Branch

git checkout -b update-name

Step 3 – Open the Repository in VS Code

code .

Add your changes, then check the status:

git add .
git status

Step 4 – Commit Your Changes

git commit -m "Brief description of what is changed"

Step 5 – Push the Branch & Open a Pull Request

  1. Push the new branch to GitHub

    git push -u origin update-name
  2. Navigate to your repository on GitHub and open a Pull Request.

Visual Guide

Opening the Project Folder

Opening the folder

Creating a New Branch

Creating a new branch

Editing Files in VS Code

Editing in VS Code

Opening a Pull Request

Pull request screen 1
Pull request screen 2

Tracking Changes with Git

Git works with three zones:

ZoneDescription
Working directoryFiles you edit locally. Git sees them but isn’t tracking them yet.
Staging areaFiles you flag for inclusion in the next commit. Use git add.
RepositoryA permanent snapshot of everything in the staging area. Use git commit.

Common Command Sequence

# See what’s happening (red files are untracked or modified)
git status

# Stage changes
git add .          # or `git add <file>` for specific files

# Record a snapshot
git commit -m "Brief description of what is changed"

Key Takeaways

  • git status is your best friend. Run it after every command to see which files are tracked, staged, or ignored.
  • Use git add to move changes from the working directory to the staging area.
  • Use git commit to create a permanent snapshot in the repository.
  • Always create a new branch for a feature or fix, then open a Pull Request to merge it back.
Back to Blog

Related posts

Read more »