A repository (repo) is just a folder that Git is watching. Every file you add, edit, or delete inside it — Git knows about it. Let's create one and learn the workflow you'll use every single day.
# Create a folder for your test project
mkdir selenium-tests
cd selenium-tests
# Initialize Git — this folder is now a repo
git init
# Output: Initialized empty Git repository in /selenium-tests/.git/That .git folder is where Git stores everything — all the history, all the versions. Don't touch it. Don't delete it. If you delete .git, you lose all your history.
This is the most important concept in Git. Every file lives in one of three areas. Think of it like a restaurant kitchen:
# 1. Create a test file
echo "public class LoginTest {}" > LoginTest.java
# 2. Check status — Git sees it as "untracked"
git status
# Untracked files:
# LoginTest.java
# 3. Stage the file (tell Git: "include this in my next save")
git add LoginTest.java
# 4. Check status again — now it's "staged"
git status
# Changes to be committed:
# new file: LoginTest.java
# 5. Commit — permanently save this snapshot
git commit -m "Add LoginTest skeleton"
# [main (root-commit) a1b2c3d] Add LoginTest skeleton
# 6. View your history
git log --oneline
# a1b2c3d Add LoginTest skeletonYou'll type git status dozens of times a day. It's your "where am I?" command. When you're confused, run git status first. Always.
# Stage ALL changed files at once
git add .
# See exactly what changed (before staging)
git diff
# See what's staged (before committing)
git diff --staged
# Unstage a file (oops, didn't mean to add that)
git restore --staged LoginTest.java
# Discard changes — go back to last committed version
# WARNING: this permanently deletes your uncommitted changes
git restore LoginTest.javagit restore <file> permanently throws away your uncommitted changes. There's no undo. If you're unsure, commit first or use git stash (saves your work temporarily without committing).
Q: What is the staging area in Git? Why does it exist?
A: The staging area is a middle layer between your working directory and the repository. When you run git add, files move to the staging area. When you run git commit, only staged files get committed. It exists so you can choose exactly which changes to include in a commit. For example, I might have edited 5 files but only want to commit 2 of them — the staging area lets me do that. It gives you control over what goes into each commit.
Key Point: The daily workflow is simple: edit → git add → git commit → git push. Run git status whenever you're confused.