The Git Syndrome
For a long time, Git was something to survive. Type a command. Hope nothing breaks. If it does, frantically search Google. Copy solutions from Stack Overflow without understanding. Pray you won't see merge conflicts.
The truth: most developers don't use all of Git. They use a small set of commands, deeply. Once you stop treating Git like magic, it becomes a tool you can actually trust.
The Essential Commands
1. git status Shows the current state: modified files, staged, untracked.
Common mistake: Running other commands without checking git status first. That's how you commit or delete the wrong files.
2. git init Initializes a new Git repository.
Common mistake: Running git init inside an already-initialized repo, creating a nested .git folder.
3. git clone Downloads a remote repo with all its history.
Common mistake: Cloning and immediately pushing without understanding the branch structure.
4. git add Moves changes into the staging area.
git add .: Adds changes from current directory (watch out for subfolders)git add *: Adds only non-hidden files (skips .env, .gitignore)git add :: Adds everything from repo root, including hidden files
Common mistake: Using git add . blindly and staging unwanted files.
5. git commit Records staged changes with a message.
Good habit: Clear, descriptive messages. "Fix bug" says nothing. "Fix null pointer in user auth flow" says everything.
6. git push Sends local commits to the remote.
Common mistake: Force pushing (-f) without understanding consequences on shared history.
7. git pull Fetches and merges changes from the remote.
Alternative: git fetch then git merge for more control.
8. git branch Lists, creates, or deletes branches.
Usage: git branch feature-x creates, git branch -d feature-x deletes.
9. git checkout / git switch Changes branches or restores files.
Note: git switch is the modern version for changing branches, more intuitive.
10. git merge Merges one branch into another.
Tip: Always ensure you're on the target branch before merging.
11. git log Shows commit history.
Useful options: --oneline for compact format, --graph to visualize branches.
12. git diff Shows differences between commits, branches, or files.
Common usage: git diff HEAD~1 to see changes since last commit.
13. git stash Temporarily saves uncommitted changes.
Scenario: You need to switch branches but have work in progress. git stash, switch, then git stash pop.
14. git reset Undoes commits or unstages files.
Caution: --hard destroys changes, --soft keeps them staged.
15. git rebase Rewrites history by moving commits.
Golden rule: Never rebase publicly shared branches.
The Real Git Skill
These 15 commands cover 95% of daily needs. The real skill isn't memorizing commands, it's understanding what Git does: track snapshots of your code over time.
Once you have this mental model, Git transforms from "scary magic" to "reliable tool." And when something goes wrong (it will), you'll know exactly where to look.
