← Lesson
BitWithBite
Git & GitHub · Quick Reference

Lesson 3 — Git Basics: Your First Repository Cheat Sheet

Git & GitHub
In one line: Every Git project follows the same basic cycle. Once you learn these 5 commands, you can manage any project with Git. Let's build a real project from scratch.

Key Ideas

1The Core Git Workflow. Every Git project follows the same basic cycle. Once you learn these 5 commands, you can manage any project with Git. Let's build a real project from scratch.
2git add & git commit. These two commands form the heart of Git. git add moves changes to the Staging Area. git commit saves the staged changes as a permanent snapshot.
3git log — Viewing History. After a few commits, you'll want to see your project history. git log shows every commit: who made it, when, and what the message was.
4git diff — Seeing Changes. Before committing, you often want to see exactly what changed. git diff shows you line-by-line differences.
5Writing Great Commit Messages. A commit message is a permanent record of why a change was made. Bad messages like "fix" or "update" are useless 6 months later. Good messages make you and your team v...

Code Examples

# Create a new project directory mkdir my-first-repo cd my-first-repo # Initialize Git — creates a hidden .git folder git init # Output: Initialized empty Git repository in .../my-first-repo/.git/ # Check the status of your repo git status # Output: On br...
# Create a file echo "# My Project" > README.md # Check status — README.md is "untracked" git status # Stage the file git add README.md # Or stage ALL changes at once: git add . # Check status again — file is now "staged" git status # Commit with a m...
# Full log — shows hash, author, date, message git log # Compact — one line per commit git log --oneline # Compact + visual branch graph git log --oneline --graph --all # Show last 5 commits only git log -5 # Search commits by message git log --grep="fe...