Video: Git and GitHub for Beginners — Crash Course (freeCodeCamp.org). Embedded from YouTube in privacy-enhanced mode; all rights belong to the creator.
Git is a distributed version-control system created by Linus Torvalds in 2005 to manage Linux kernel development. It records snapshots of your project so you can see what changed, when and why, undo mistakes, and work in parallel with others without overwriting each other's work. GitHub is a hosting service built around Git that adds collaboration: pull requests, code review, issues, Actions for CI/CD, and free static hosting with GitHub Pages.
Core concepts in plain English
- Repository — a project folder plus its full history (stored in a hidden
.gitdirectory). - Commit — a saved snapshot with a message, author and timestamp. Each commit has a unique SHA-1 (or SHA-256) hash ID.
- Staging area — the waiting room where you choose exactly which changes go into the next commit.
- Branch — a movable pointer to a line of commits, letting you develop a feature in isolation.
- Remote — a copy of the repository elsewhere, typically on GitHub, named
origin.
The ten commands you'll use daily
git clone <url> # copy a remote repo to your machine
git status # what's changed and what's staged
git add <file> / git add -p # stage changes (-p = choose hunks)
git commit -m "message" # record a snapshot
git log --oneline --graph # compact history
git switch -c feature-x # create and move to a new branch
git pull # fetch + merge remote changes
git push -u origin feature-x # publish your branch
git diff # unstaged changes
git restore <file> # discard local changes to a file
A healthy workflow
- Pull the latest
main. - Create a short-lived branch for one change.
- Commit small, logical steps with messages that explain why.
- Push and open a pull request; let CI run tests.
- Request review, address feedback, then merge (squash merges keep history tidy).
- Delete the branch.
Writing good commit messages
Use the imperative mood (“Add password strength meter”, not “Added…”), keep the subject under about 50 characters, and use the body to explain context. Future you — and anyone running git blame — will be grateful.
Undoing things safely
| Situation | Command |
|---|---|
| Fix the last commit message | git commit --amend |
| Unstage a file | git restore --staged file |
| Undo a pushed commit | git revert <sha> (creates an inverse commit) |
| Recover “lost” work | git reflog |
Avoid git push --force on shared branches; if you must, use --force-with-lease, which refuses to overwrite commits you haven't seen.
Never commit secrets
API keys pushed to a public repository are typically found by automated scanners within minutes. Add .env to .gitignore, use your platform's secret store, and if a secret leaks, rotate it immediately — deleting the commit isn't enough because history and forks persist.
Try the tools
Text Diff Checker
Compare two texts line-by-line or word-by-word.
Unix Timestamp Converter
Convert epoch seconds/milliseconds to dates and back.