- Git: Your Code’s Time Machine
- Setting Up Git: The Seattle Coffee Shop Way
- Your First Repository: Starting Fresh
- The Three Stages of Git: A Bento Box Analogy
- Basic Git Commands: My Daily Workflow
- Branches: The Multiverse of Code
- The Mistakes Everyone Makes (Yes, Even After 7 Years)
- Collaboration: The Seattle Tech Scene Way
- My .gitignore Wisdom
- Git Workflows: From Chaos to Order
- Git Tips from the Trenches
- The Life-Saving Commands
- Cultural Git: East Meets West
- Final Thoughts: Git Is Your Friend
Git for Beginners: How I Almost Lost Three Months of Code (And What Saved Me)
It was my first week as an intern at a Taipei startup, and I had just finished three months of work on a new feature. Feeling proud, I decided to “clean up” my computer. One rm -rf
command later, my entire project was gone. No backup. No version control. Just me, staring at an empty directory, wondering if I should just walk into the Pacific Ocean.
My supervisor found me nearly in tears. “沒有用 Git?” (You didn’t use Git?), he asked. That day changed my entire approach to coding. Now, seven years later in Seattle, I can’t imagine life without Git. Let me share what I wish I’d known back then.
Git: Your Code’s Time Machine
Think of Git like those checkpoint saves in video games. You know when you’re about to face a boss in Hades (yes, I’m still playing it), and the game auto-saves? Git is like that, but you decide when to create the checkpoint.
# My actual commits from last Friday night
git log --oneline -5
# f3a2b1c Fix payment bug (finally!)
# 89def12 Add more coffee
# 234abc9 WHY IS THIS NOT WORKING
# 567def1 Revert "This will definitely work"
# 890abc2 This will definitely work
We’ve all been there.
Setting Up Git: The Seattle Coffee Shop Way
I set up Git on every new machine like I set up a new coffee shop workspace:
# First, tell Git who you are (like giving your name for the order)
git config --global user.name "Maya Chen"
git config --global user.email "[email protected]"
# Set your favorite editor (mine's VS Code, obviously)
git config --global core.editor "code --wait"
# Make Git output prettier (like latte art for your terminal)
git config --global color.ui auto
Your First Repository: Starting Fresh
Remember your first day at a new job? Creating your first Git repo feels like that:
# Create a new project (like finding a good spot at the library)
mkdir bubble-tea-tracker
cd bubble-tea-tracker
# Initialize Git (claiming your workspace)
git init
# Check status (looking around nervously)
git status
# Output: "On branch main. No commits yet"
The Three Stages of Git: A Bento Box Analogy
Git has three main areas, which I think of like preparing a bento box:
- Working Directory - Your kitchen counter (where you prep)
- Staging Area - The bento box (where you arrange)
- Repository - The fridge (where you store)
# You make changes (chopping vegetables)
echo "# Bubble Tea Consumption Tracker" > README.md
# Add to staging (placing in bento box)
git add README.md
# Commit (storing in fridge)
git commit -m "Initial commit: Start tracking my bubble tea problem"
Basic Git Commands: My Daily Workflow
Here’s my actual morning routine at RainCity FinTech:
# 8:00 AM - Coffee #1, check what happened overnight
git pull origin main
git status
# 9:30 AM - Start new feature
git checkout -b feature/add-payment-validation
# 10:15 AM - Coffee #2, make changes
# ... coding ...
# 11:00 AM - See what I've done (usually more than I remember)
git diff
# 11:30 AM - Stage the good stuff
git add src/payment.py
git add tests/test_payment.py
# 11:45 AM - Commit before lunch
git commit -m "Add payment validation for amounts over $10,000"
# 2:00 PM - Push before coffee #3
git push origin feature/add-payment-validation
Branches: The Multiverse of Code
Coming from a physics background (my mom the math teacher would be proud), I think of branches like parallel universes:
# The main timeline (production)
main: ----A----B----C----D
# My experimental timeline
feature: \--E----F
# That weird fix I tried at 2 AM
hotfix: \--G
Real example from last week:
# Working on a new feature
git checkout -b feature/bubble-tea-expenses
# Meanwhile, production breaks
git checkout main
git checkout -b hotfix/payment-rounding-error
# Fix the issue
# ... emergency coding ...
git add .
git commit -m "Fix: Round payments to 2 decimal places"
# Merge the fix
git checkout main
git merge hotfix/payment-rounding-error
# Back to my feature
git checkout feature/bubble-tea-expenses
git merge main # Get the hotfix into my feature branch
The Mistakes Everyone Makes (Yes, Even After 7 Years)
The “Oh No, I Committed to Main” Panic
Last month, at 11 PM, powered by bubble tea and hubris:
# What I did (don't do this)
git add .
git commit -m "Major refactoring"
git push origin main # 😱
# What I should have done
git checkout -b refactor/payment-service
# ... then commit and push to the branch
The “Wrong Commit Message” Regret
# What I typed at 2 AM
git commit -m "stuff"
# Fixing it (if not pushed yet)
git commit --amend -m "Refactor payment validation to handle edge cases"
# If already pushed (and you're brave)
# Don't do this on shared branches!
git push --force origin feature/my-branch
The “I Deleted Everything” Disaster
This happened to a junior dev on my team last week:
# They did this
git checkout . # Wanted to discard changes
# But actually deleted their uncommitted work
# What saved them: Git's reflog
git reflog
# Found their last good state
git checkout HEAD@{1}
Collaboration: The Seattle Tech Scene Way
Working with others on Git is like coordinating coffee runs for the team:
# Start your day (get everyone's updates)
git pull origin main
# Create your feature branch
git checkout -b feature/add-taiwanese-payment-methods
# Work on your feature
# ... code code code ...
# Share with the team
git push origin feature/add-taiwanese-payment-methods
# Create a pull request (like saying "hey, check this out!")
# Usually done on GitHub/GitLab/Bitbucket
My .gitignore Wisdom
After accidentally committing my AWS keys (don’t ask), I’m religious about .gitignore:
# Python projects (learned at Amazon)
__pycache__/
*.pyc
.env
venv/
.DS_Store # Mac's annoying files
# Node projects (learned at Microsoft)
node_modules/
.env.local
.env.*.local
npm-debug.log*
# Personal stuff (learned the hard way)
.idea/ # PyCharm
.vscode/ # VS Code settings
*.swp # Vim swap files
personal-notes.txt
DONT-COMMIT-THIS/
Git Workflows: From Chaos to Order
My Personal Project Workflow
# Start the day
git checkout main
git pull origin main
# New feature
git checkout -b feature/track-caffeine-intake
# Small, focused commits
git add src/caffeine_tracker.py
git commit -m "Add function to calculate daily caffeine"
git add tests/test_caffeine.py
git commit -m "Add tests for caffeine calculator"
# Push and create PR
git push origin feature/track-caffeine-intake
Team Workflow at RainCity FinTech
# Morning sync
git checkout develop
git pull origin develop
# Feature branch from develop
git checkout -b feature/RAIN-1234-payment-retry
# Work work work...
# Commit often, push at least daily
# Before creating PR
git checkout develop
git pull origin develop
git checkout feature/RAIN-1234-payment-retry
git rebase develop # Keep history clean
# Push and PR
git push origin feature/RAIN-1234-payment-retry
Git Tips from the Trenches
The “Undo” Cheat Sheet I Keep on My Monitor
# Undo last commit (keep changes)
git reset --soft HEAD~1
# Undo last commit (discard changes)
git reset --hard HEAD~1
# Undo changes to a file
git checkout -- filename.py
# "I've made a huge mistake" - go back to remote state
git fetch origin
git reset --hard origin/main
The Commit Message Formula
After reviewing thousands of commits at Microsoft, here’s my formula:
Type: Brief description (50 chars max)
Longer explanation if needed. Explain why, not what.
The code shows what; the commit message shows why.
Fixes: #123
References: #456
Real example:
Fix: Payment validation for negative amounts
Previous validation only checked for null/undefined.
Discovered that negative amounts could slip through
when using certain payment providers.
Added explicit check for amount >= 0.
Fixes: RAIN-2234
The Life-Saving Commands
These have saved me more times than Seattle rain has ruined my hair:
# "What did I do yesterday?" (Great for standups)
git log --oneline --author="Maya" --since="yesterday"
# "What files did I change?"
git diff --name-only HEAD~1
# "Show me everything about this bug"
git log -S "payment_validation" --source --all
# "I need to save this work but switch branches"
git stash save "WIP: Payment refactoring"
git checkout other-branch
# ... later ...
git stash pop
Cultural Git: East Meets West
Working in both Taiwanese and American companies taught me different Git philosophies:
Taipei Style: Lots of small, incremental commits
git commit -m "Add payment function"
git commit -m "Add payment validation"
git commit -m "Add payment tests"
git commit -m "Fix payment edge case"
Seattle Style: Larger, feature-complete commits
git commit -m "Add complete payment processing with validation and tests"
I’ve found a middle ground: commit often locally, then squash before pushing:
# After many small commits
git rebase -i HEAD~4
# Mark commits as 'squash' except the first
Final Thoughts: Git Is Your Friend
That terrifying day in Taipei when I lost three months of work? It never happened again. Now, I commit so often my teammates joke that my Git history looks like my bubble tea consumption log - frequent and well-documented.
Git isn’t just about backing up code. It’s about confidence. The confidence to experiment, knowing you can roll back. The confidence to collaborate, knowing you won’t step on toes. The confidence to deploy on Friday afternoon (okay, maybe not that confident).
To new developers reading this: Git will feel overwhelming at first. You’ll mess up commits, accidentally push to main, and frantically Google “how to undo git merge.” That’s normal. We’ve all been there.
Start simple. Add, commit, push. The fancy stuff can wait. And remember - in Git, almost everything is recoverable. Unlike that time I spilled bubble tea on my keyboard. That was not recoverable.
Writing this from the Seattle Public Library, 10th floor, with a perfect view of the Space Needle and my third commit of the day. Got a Git horror story or a life-saving command? Tweet me @maya_codes_pnw. Remember: commit early, commit often, and may your merges always be conflict-free! 🌸
Add Comment
No comments yet. Be the first to comment!