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
- 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.
- 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.
- Branch: an independent line of development. You can work on a branch without touching the main line. New GitHub repositories use
mainas 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:
- Make a folder and move into it:
mkdir my-first-repo cd my-first-repo - Turn the folder into a Git repository:
Git creates a hiddengit init.gitfolder, which is where the history is stored. The folder is now a repository. - 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.
- Create a file, for example
README.md, containing one line of text. - Stage it, which means choosing what goes into the next snapshot:
(git add README.mdgit add .stages every changed file in the folder.) - Record the snapshot with a clear message:
git commit -m "Add README" - Check your work:
git statusshows what is staged, andgit loglists 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
- Create a new branch:
This only creates the branch. You are still ongit branch add-intromain. - Move onto it:
git switch add-intro - Shortcut that creates the branch and switches to it in one step:
git switch -c add-intro - Run
git branchwith no name to list branches. The current one is marked with*. - Edit
README.md, then rungit addandgit commitagain. The new commit exists only onadd-intro.mainis unchanged. - 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, thengit commit. - A branch is an independent line of development.
git branchcreates one, andgit switchmoves to it. git switch -c <name>creates a branch and switches to it in one step.