LevelUpWith

Explore / GitHub Foundations (GH-900) Exam Prep / Lesson 2

Lesson 2: Git vs GitHub: Repositories, Commits, Branches

[Understand Git and GitHub basics] Explains the difference between Git and GitHub. Then identifies the key Git concepts (repositories, commits and branches) with a short walkthrough of basic git commands.

Free to read, no account needed. Part of GitHub Foundations (GH-900) Exam Prep.

By the end of this level you'll be able to

  • Explain the difference between Git (a distributed version control tool) and GitHub (a cloud platform that hosts Git repositories)
  • Run git init, git add, git commit, git branch and git switch, and say what each one does
  • Identify a repository, a commit and a branch in exam questions

Before you start

This course follows Microsoft's Study guide for Exam GH-900: GitHub Foundations. The guide belongs to Microsoft, is free on Microsoft Learn, and is not reproduced here. This course is independent: GitHub and Microsoft do not endorse it, and it cannot promise that you will pass.

This level covers two bullets from the domain Understand Git and GitHub basics (25–30%):

  • Explain the difference between Git and GitHub
  • Identify key Git concepts such as repositories, commits, and branches

Step 1: Separate Git from GitHub

In Level 1 you learned what version control does. Now meet the two names the exam expects you to keep apart.

Git GitHub
What it is A distributed version control system, a program you install A cloud platform that hosts Git repositories
Where it runs Your own computer The web (github.com)
What it does Records the history of your files Stores repositories online and adds collaboration tools
Needs internet? No. Every copy holds the full history. Yes

GitHub's documentation calls Git "the most popular distributed version control system". It says GitHub "hosts Git repositories and provides developers with tools to ship better code."

Analogy: Git is the camera that takes the photos. GitHub is the online album where you store and share them, and where others can comment.

Distributed means every copy of a repository on every computer has the complete history. You can commit on a plane with no connection and share your work later.

Do this: Say the difference out loud in one sentence: "Git is the tool that tracks changes. GitHub is the platform that hosts Git repositories online."

Step 2: Learn the three key concepts

  1. Repository (repo): GitHub Docs defines this as "the entire collection of files and folders associated with a project, along with each file's revision history." It is the project folder plus its memory.
  2. Commit: a saved snapshot of the project at one moment, with a message that describes the change. Commits link together to form the project's history.
  3. Branch: an independent line of development. You can work on a branch without touching the main line. New GitHub repositories use main as the default branch.

Analogy: The repository is a notebook. Each commit is a dated page. A branch is a sticky-note tab where you draft ideas without changing the clean copy.

Step 3: Create a repository with git init

Install Git from git-scm.com, open a terminal and follow these steps:

  1. Make a folder and move into it:
    mkdir my-first-repo
    cd my-first-repo
    
  2. Turn the folder into a Git repository:
    git init
    
    Git creates a hidden .git folder, which is where the history is stored. The folder is now a repository.
  3. Tell Git who you are (once per computer). Git attaches this name and email to every commit:
    git config --global user.name "Your Name"
    git config --global user.email "you@example.com"
    

Note: If you haven't set a default branch name, plain Git may call the first branch master. Run git config --global init.defaultBranch main to match GitHub.

Step 4: Save a snapshot with git add and git commit

Saving a change takes two steps: stage it, then commit it.

  1. Create a file, for example README.md, containing one line of text.
  2. Stage it, which means choosing what goes into the next snapshot:
    git add README.md
    
    (git add . stages every changed file in the folder.)
  3. Record the snapshot with a clear message:
    git commit -m "Add README"
    
  4. Check your work: git status shows what is staged, and git log lists your commits.

Analogy: git add puts items into the box. git commit seals and labels the box.

Step 5: Work on a branch with git branch and git switch

  1. Create a new branch:
    git branch add-intro
    
    This only creates the branch. You are still on main.
  2. Move onto it:
    git switch add-intro
    
  3. Shortcut that creates the branch and switches to it in one step:
    git switch -c add-intro
    
  4. Run git branch with no name to list branches. The current one is marked with *.
  5. Edit README.md, then run git add and git commit again. The new commit exists only on add-intro. main is unchanged.
  6. Return with git switch main.

Note: Older guides, including some GitHub Docs pages, use git checkout <branch> to switch. git switch was added in Git 2.23 (2019) for exactly this job.

Command summary

Command What it does
git init Turns the current folder into a new repository
git add Stages changes for the next commit
git commit -m "..." Saves the staged changes as a snapshot with a message
git branch <name> Creates a branch but does not switch to it
git switch <name> Moves to an existing branch
git switch -c <name> Creates a branch and switches to it

What the exam asks about this

GH-900 questions on this topic are usually short definitions or scenarios. Expect to:

  • Choose which statement describes Git (a local, distributed tool) and which describes GitHub (a cloud hosting and collaboration platform).
  • Match a description to the right term: "a snapshot of changes" is a commit, "a separate line of development" is a branch, and "project files plus their full history" is a repository.
  • Spot the false claim. Git does not need GitHub or an internet connection to record history.
  • Put steps in order: git init → git add → git commit.

Key takeaways

  • Git is a distributed version control system that runs on your computer. GitHub is a cloud platform that hosts Git repositories and adds collaboration tools.
  • A repository holds a project's files and their complete revision history.
  • A commit is a snapshot with a message. Saving one takes two steps: git add, then git commit.
  • A branch is an independent line of development. git branch creates one, and git switch moves to it.
  • git switch -c <name> creates a branch and switches to it in one step.

A 6-question knowledge check follows this lesson in the app, free and without an account.

Keep going: levels 3 and 4 are free

Create a free account to open the next two levels, save your progress and pick up where you left off. No card needed.

Next: Level 3, GitHub Accounts, Organizations and Enterprise.

Create a free account →See the whole course

More like this

  • Power BI from Zero: Build, Publish and Share a Report

    Start from Excel and build one complete Power BI report from a small sample sales dataset. You will connect and clean the data, build a star-shaped model, writ…

    Course · Microsoft · Data & Analytics · Capable · 18 levels · 4 free · Professionally curated by levelupwith.com

  • Microsoft Fabric Data Engineer (DP-700) Exam Prep

    Prepare for Microsoft's DP-700 exam by working through every bullet in the study guide. Each level uses short T-SQL, PySpark and KQL examples, portal steps and…

    Exam prep · DP-700 · Data & Analytics · Expert · 40 levels · 4 free · Professionally curated by levelupwith.com

  • Microsoft Azure Fundamentals (AZ-900) Exam Prep

    Learn to pick the cloud model, service type or Azure service that fits a scenario and explain why the alternatives do not, across every skill in the 20 July 20…

    Exam prep · AZ-900 · Cloud & Compute · Capable · 17 levels · 4 free · Professionally curated by levelupwith.com

  • Microsoft Azure Administrator (AZ-104) Exam Prep

    Work through every bullet of the AZ-104 skills measured as of April 17, 2026, learning each task in the Azure portal, Azure CLI, PowerShell, and ARM templates…

    Exam prep · AZ-104 · Cloud & Compute · Expert · 60 levels · 4 free · Professionally curated by levelupwith.com

  • Support Pro: Helping Users Move to Microsoft 365

    Help users get through a move from Google Workspace to Microsoft 365, from the week before cutover to the first tickets afterwards. You will learn what moves a…

    Course · Microsoft · Suite Support Pro: Configure and Fix · Expert · 40 levels · 4 free · Professionally curated by levelupwith.com

  • Microsoft 365 Support Pro: Copilot for End Users

    Learn to work out which Copilot a user actually has, and to fix the everyday Copilot tickets: missing buttons, licence and sign-in problems, files Copilot can'…

    Course · Microsoft · Suite Support Pro: Configure and Fix · Expert · 36 levels · 4 free · Professionally curated by levelupwith.com