Git and GitHub Explained Simply

Git and GitHub Explained Simply

What Are Git and GitHub? Save Points for Your Project

Git is a tool that saves change history for your project right on your computer, so you can go back to an old version if you accidentally break something. GitHub is where you store that history online for backup, sharing, and team collaboration. Once you build an app with AI, these two tools keep your work safe forever.

Good news: you barely type Git commands by hand. Claude Code does it for you. Your job is understanding the concepts so you know when to save, can read history, and recognize dangerous commands before confirming them.

Understand with a Real-World Example

Imagine playing a long video game. Before each hard level, you create a save point. If you lose, you load the nearest save instead of replaying from the start.

  • Each time you save is a commit: a "snapshot" of your entire project at that moment, with a note.
  • The list of saves is your history (log).
  • To try a risky path without losing your good progress, you make a copy to experiment with. That's a branch.
  • GitHub is like saving to the cloud: if your computer breaks, your game is still there, and friends can pick up where you left off.

How It Works

Git workflow has four levels:

  1. Working directory: where you (or Claude) edit files normally.
  2. Staging area: you mark which changes will be saved next time.
  3. Local repository: the commit command takes marked changes and stores them in your machine's history.
  4. GitHub: push sends history to the internet; pull brings new changes back to your machine.

Core commands so you can read them when Claude asks permission:

git init                    # Initialize Git in this folder
git status                  # See which files changed
git add .                   # Mark changes for next save
git commit -m "message"     # Save a checkpoint with a note
git log --oneline           # View commit history, one per line
git switch -c new-feature   # Create and switch to new branch
git push                    # Upload to GitHub
git pull                    # Download latest changes

Each command explained:

  • git init: turns a folder into a Git repository (creates hidden .git folder to store history). Do this once per project.
  • git status: the question "where am I?", shows which files changed and which are ready to save. You'll use this most.
  • git add .: mark changes for next save. The dot means "all"; you can specify one file instead.
  • git commit -m "...": save a checkpoint with a short description, so you know later what changed.
  • git log --oneline: see all checkpoints, one line each.
  • git switch -c [branch-name]: create a new branch and switch to it.
  • git push / git pull: upload to and download from GitHub.

The most common rhythm repeats three steps: edit file, git add, git commit. Push to GitHub occasionally for backup.

Branches: Experiment Safely, Merge When Ready

The main branch is usually called main. This is the "real" version and must always work. When trying a new feature or fixing something risky, don't edit main directly. Create a separate branch:

  1. Create branch: Git creates a new path branching from a point on main. New commits stay on this branch, main stays untouched.
  2. Work on branch: experiment freely. If it breaks, only this branch breaks, your live product is safe.
  3. Merge: when the feature works, merge the branch back into main, either directly or through a Pull Request on GitHub (propose merging so others review first).

This way multiple features or multiple people work in parallel on different branches, each person responsible for their own. Failed experiments disappear, main never gets touched. For advanced use, you can run five Claude instances in parallel using git worktrees, each on its own branch.

What This Means for You: Let Claude Code Handle the Commands

In Claude Code, you just speak naturally. Claude runs the Git commands and shows you the command before asking permission. Sample commands you can use immediately:

Initialize git for this folder, create a repo on GitHub, and push.
Commit current changes with description "add CSV export", then push.
What changed compared to the last commit?
Create branch experiment-chart and switch to it.
I broke it, go back to the state from the previous commit.

Claude reads the repository state, writes clean commit descriptions automatically, creates branches, and if GitHub's gh tool is installed it can even open Pull Requests for you.

Three habits worth keeping:

  • Commit every time something works. Just finished a feature and it runs? Tell Claude to commit. That's your save point.
  • Push to GitHub at end of day. Computer breaks, you still have the project intact.
  • Try new things on separate branches. Especially when Claude makes big changes or swaps libraries.

🐙 What GitHub Offers

On GitHub, each project is a repo (repository), with:

SectionPurpose
CommitsHistory of all saves, who changed what and when
Pull RequestsPropose merging a branch into main for others to review first
IssuesList of bugs and to-do items
ActionsAutomatically run tests or deploy when you push

Actions is the next step once you're comfortable: every push, GitHub automatically tests and updates your website. Read more about turning GitHub into an automation machine with Claude Code.

Common Misunderstandings

  • "Git and GitHub are the same." No. Git runs on your machine and works offline. GitHub is an online service to store and share Git repos. You can use Git without GitHub.
  • "With Claude I don't need to understand Git." Claude types commands well, but you approve them. Two commands need careful reading: git reset --hard (delete unsaved changes) and git push --force (rewrite GitHub history and can destroy others' work).
  • "Pushing to GitHub means everyone sees it." Only if your repo is public. Private repos only you and invited people see. Still, never commit passwords or API keys: keep them in .env and add that file to .gitignore, as explained in What is a Tech Stack?.

Frequently Asked Questions

How do Git and GitHub differ?

Git saves change history on your machine. GitHub stores that history online for backup, sharing, and teamwork.

How often should I commit?

After each working checkpoint, like finishing a button and testing it. Small, frequent commits help you jump back to the right spot if something breaks.

I don't code. Do I need to learn Git commands?

No need to memorize. Just understand commit, branch, push, pull so you can ask Claude Code in plain language and read commands before approving.

If I break the app, how do I fix it?

Tell Claude: "I broke it, go back to the previous commit." If you commit regularly, this takes seconds.

Does a GitHub repo cost money?

Free accounts get unlimited private repos, enough for personal projects and small teams.


Related: What is Claude Code? | Automate with GitHub | Tech Stack Reference

More articles