A Beginner's Guide on Git & GitHub for Version Control

Published: (January 15, 2026 at 02:16 PM EST)
2 min read
Source: Dev.to

Source: Dev.to

Cover image for A Beginner's Guide on Git & GitHub for Version Control

Introduction

Version control helps developers track code changes and collaborate more effectively. Git and GitHub are tools that make this possible. Git is a version‑control system, while GitHub is an online platform that stores projects in the cloud. In this article you’ll learn the basic Git commands used for version control.

Getting Started

  • Download and install Git from the official website.
  • After installation, configure Git with your name and email address:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"

Git Commands for Version Control

  • git init – Initializes a directory so Git can start tracking changes.
  • git clone – Makes a copy of a GitHub repository on the local machine.
  • git add – Adds files to the staging area.
  • git commit – Saves the files that were added to the staging area.
  • git push – Sends recent commits from your local repository to GitHub.
  • git pull – Fetches and updates your local repository with changes from GitHub.

Initializing a Git Repository

We’ll use a simple example project called my‑first‑repo to demonstrate how the Git commands work.

  1. Create a project folder and navigate into it.

  2. Initialize the repository:

    git init

    Initialize repository screenshot

  3. Create a file in the project folder and check its status:

    git status

    Check status screenshot

  4. Add files to the staging area and commit them:

    git add .
    git commit -m "Initial commit"

    Add and commit screenshot

  5. Push to GitHub

    • Create a new repository on GitHub.
    • Copy the repository URL.
    • Connect your local project and push:
    git remote add origin 
    git branch -M main
    git push -u origin main

    Push to GitHub screenshot

    Push result screenshot

    Your project is now available on GitHub.

Git Collaboration and Conflict Resolution

You can collaborate effectively by creating branches. Branching allows each collaborator to work on the same project without interfering with each other.

  • git branch – Create a new branch.
  • git checkout – Switch to the specified branch.
  • git merge – Merge the branch into the current branch (e.g., main).

Conclusion

Git and GitHub are essential tools for every developer. With just a few basic commands—git init, git add, git commit, git push, and git pull—you can track your work, collaborate with others, and safely manage your code. Practicing these commands will build your confidence in version control.

Back to Blog

Related posts

Read more »

WEEK 1 ASSIGNMENT.

Git Git is a version control system used for code collaboration, tracking code changes and who made them. Common Git commands bash git --version Checks whether...

Day 1 of Learning Linux & GitHub 🚀

markdown !Forem Logohttps://media2.dev.to/dynamic/image/width=65,height=,fit=scale-down,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2...

Git Learning

What is Git Git was created by Linus Torvalds in 2005. Version Control Systems Types of Version Control Systems 1. Local VCS - Example: none provided - Limitat...