Courses/Git/Introduction to Version Control

    Lesson 1 โ€ข Beginner

    Introduction to Version Control ๐ŸŒฟ

    Discover why version control exists, how Git tracks every change, and set up your first repository โ€” the foundation every developer needs.

    What You'll Learn in This Lesson

    • โ€ข What version control is and why every developer uses it
    • โ€ข How Git tracks changes with snapshots (not diffs)
    • โ€ข Git's three areas: Working Directory, Staging, Repository
    • โ€ข Installing and configuring Git for the first time
    • โ€ข Creating your first repository and making your first commit

    1๏ธโƒฃ What is Version Control?

    Version control is a system that records changes to files over time. Without it, you end up with folders full of "final_v2_ACTUALLY_FINAL.zip" files. Git is the world's most popular version control system โ€” created by Linus Torvalds (the creator of Linux) in 2005. It's distributed, meaning every developer has the full project history on their machine.

    Try It: Version Control

    See why Git beats the 'rename everything' approach

    Try it Yourself ยป
    JavaScript
    // What is Git? โ€” Version Control Explained
    console.log("=== What is Version Control? ===");
    console.log("Version control is a system that tracks changes to files over time.");
    console.log("It lets you go back to any previous version, see who changed what,");
    console.log("and collaborate with others without overwriting each other's work.");
    console.log();
    
    // Simulating a file's version history
    console.log("=== A File's History (Like Google Docs) ===");
    const history = [
      { version: 1, author: 
    ...

    2๏ธโƒฃ Installing & Configuring Git

    Git is available on every operating system. After installing, you need to configure your name and email โ€” these are embedded in every commit you make so your team knows who changed what.

    Try It: Installation & Config

    Set up Git on your machine and configure your identity

    Try it Yourself ยป
    JavaScript
    // Installing and Configuring Git
    console.log("=== Installing Git ===");
    console.log();
    console.log("Windows:");
    console.log("  Download from: https://git-scm.com/download/win");
    console.log("  Or: winget install Git.Git");
    console.log();
    console.log("macOS:");
    console.log("  xcode-select --install");
    console.log("  Or: brew install git");
    console.log();
    console.log("Linux (Ubuntu/Debian):");
    console.log("  sudo apt update && sudo apt install git");
    console.log();
    console.log("Linux (Fedora):");
    ...

    3๏ธโƒฃ Git's Three Areas

    Understanding Git's three areas is the key to mastering it. The Working Directory is your actual files. The Staging Area is where you prepare changes for a commit. The Repository is the permanent history. Think of it as: edit โ†’ stage โ†’ commit.

    Try It: Three Areas

    Watch files move through Working โ†’ Staging โ†’ Repository

    Try it Yourself ยป
    JavaScript
    // Git Concepts โ€” The Three Areas
    console.log("=== Git's Three Areas ===");
    console.log();
    console.log("  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    git add    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   git commit   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”");
    console.log("  โ”‚  Working     โ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€> โ”‚  Staging      โ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€> โ”‚  Repository โ”‚");
    console.log("  โ”‚  Directory   โ”‚             โ”‚  Area (Index) โ”‚             โ”‚  (.git)     โ”‚");
    console.log("  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  <โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜             โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜");
    console.log("                   git r
    ...

    4๏ธโƒฃ Your First Repository

    Use git init to create a new repository, git add to stage files, and git commit to save a snapshot. Use git status constantly โ€” it tells you exactly what's happening.

    Try It: First Repository

    Create a repo, add files, and make your first commit

    Try it Yourself ยป
    JavaScript
    // Creating Your First Repository
    console.log("=== git init โ€” Start a New Project ===");
    console.log();
    console.log("  $ mkdir my-project");
    console.log("  $ cd my-project");
    console.log("  $ git init");
    console.log("  Initialized empty Git repository in /my-project/.git/");
    console.log();
    
    console.log("=== What git init Creates ===");
    console.log("  my-project/");
    console.log("  โ””โ”€โ”€ .git/             โ† Hidden folder (the repository!)");
    console.log("      โ”œโ”€โ”€ HEAD          โ† Points to current b
    ...

    โš ๏ธ Common Mistakes

    โš ๏ธ
    Forgetting git add โ€” Modified files aren't committed until you stage them first. Always git add before git commit.
    โš ๏ธ
    Not setting user name/email โ€” Git will warn you on your first commit. Set these globally with git config --global.
    ๐Ÿ’ก
    Pro Tip: Run git status after every command when learning. It's the best way to understand what Git is doing.

    ๐Ÿ“‹ Quick Reference โ€” Essential Git Commands

    CommandWhat It Does
    git initCreate a new repository
    git statusSee what's changed
    git add fileStage a file for commit
    git commit -m "msg"Save a snapshot
    git log --onelineView commit history
    git config --globalSet global settings

    ๐ŸŽ‰ Lesson Complete!

    You now understand version control and can create your first Git repository. Next, we'll master the daily workflow: clone, add, and commit!

    Sign up for free to track which lessons you've completed and get learning reminders.

    Cookie & Privacy Settings

    We use cookies to improve your experience, analyze traffic, and show personalized ads. You can manage your preferences below.

    By clicking "Accept All", you consent to our use of cookies for analytics and personalized advertising. You can customize your preferences or reject non-essential cookies.

    Privacy Policy โ€ข Terms of Service