What Is Git and Why Should You Learn It?

Git is a version control system — software that tracks changes to your files over time. It lets you save snapshots of your work, collaborate with others without overwriting each other's changes, and roll back to an earlier version if something breaks. GitHub is a cloud platform that hosts Git repositories, making it easy to share and collaborate on code.

Whether you're a developer, a student, or someone managing text-based projects, Git is one of the most valuable skills you can develop. Let's get you set up from scratch.

Step 1: Install Git

Download Git from the official site at git-scm.com. Follow the installer for your operating system:

  • Windows — Run the .exe installer. Accept the defaults unless you have a reason to change them. Git Bash will be installed alongside.
  • macOS — Run xcode-select --install in Terminal, or install via Homebrew with brew install git.
  • Linux (Debian/Ubuntu) — Run sudo apt update && sudo apt install git.

Verify the installation by opening a terminal and running:

git --version

You should see a version number like git version 2.43.0.

Step 2: Configure Your Identity

Git attaches your name and email to every commit you make. Set these once globally:

git config --global user.name "Your Name"
git config --global user.email "you@example.com"

You can verify your settings at any time with git config --list.

Step 3: Create a Local Repository

Navigate to the folder where your project lives (or create a new one), then initialize a Git repository:

mkdir my-project
cd my-project
git init

This creates a hidden .git folder that tracks everything. Your folder is now a Git repository.

Step 4: Make Your First Commit

  1. Create a file — for example, README.md — and add some content.
  2. Stage the file: git add README.md (or git add . to stage everything).
  3. Commit the staged changes: git commit -m "Initial commit"

The -m flag lets you attach a message to the commit. Write clear, descriptive messages — your future self will thank you.

Step 5: Connect to GitHub and Push

  1. Create a free account at github.com.
  2. Click New Repository, give it a name, and don't initialize with a README (since you already have one locally).
  3. Copy the remote URL provided (HTTPS or SSH).
  4. Link your local repo to GitHub: git remote add origin https://github.com/yourusername/my-project.git
  5. Push your commits: git push -u origin main

Refresh your GitHub page — your files are now live in the cloud.

Essential Git Commands to Remember

  • git status — See what's changed and what's staged.
  • git log — View commit history.
  • git pull — Fetch and merge changes from the remote.
  • git branch feature-name — Create a new branch for isolated work.
  • git checkout branch-name — Switch between branches.

You're Ready

You've installed Git, made your first commit, and pushed to GitHub. From here, explore branching and merging to unlock the real power of version control. The Git documentation at git-scm.com/doc is thorough and beginner-friendly if you want to go deeper.