hey everyone!!! 👋 omg so i just finished my first month as an intern and let me tell you about my journey with git... it's been a WILD ride! 🎢
day 1: "git push origin main" seemed fine until jacob was like "WHO PUSHED TO MAIN???" 😱 apparently that's
not something we do... oops!
the basics (what i learned the hard way 😅)
# first things first - NEVER work directly on main! git checkout -b my-awesome-feature # create a new branch # save your changes git add . # stage all changes git commit -m "did stuff!" # save changes with a message # get latest changes from main git checkout main git pull git checkout my-awesome-feature git merge main # update your branch
fun fact: git was created by linus torvalds (the linux guy!) because he got annoyed with other version
control systems. same energy as me making a discord bot because i got tired of manually checking PR status
😆
things that confused me at first 🤔
- what's the difference between merge and rebase?
- why do we need staging (git add)?
- what's a "detached HEAD"? (sounds scary tbh)
- why does everyone keep talking about forks? 🍴
my git cheat sheet! 📝
# oops i committed to the wrong branch! git reset HEAD~1 # undo last commit but keep changes git stash # save changes for later git checkout correct-branch git stash pop # get changes back # help i broke something! git status # see what's going on git log # check commit history git reset --hard HEAD # nuclear option (BE CAREFUL!) # keeping your branch updated git fetch # get latest info git rebase origin/main # put your changes on top of main
protip from jacob: "Always write clear commit messages. Future you will thank past you." (he was right...
past me was terrible at this 😅)
branching strategy that actually makes sense! 🌳
- main branch = production code (DON'T TOUCH!)
- feature branches = where we actually work
- naming convention: feature/what-im-doing
- delete branches after they're merged
that time i tried to force push to main because "git push" wasn't working... jacob had enabled branch
protection like 5 minutes before 😅 saved by the bell!
git commands i use every day now ⭐
# checking stuff git status # what's changed? git diff # what exactly changed? git log --oneline # commit history but pretty # branching git checkout -b feature/awesome-thing git branch -d old-branch # cleanup! # fixing mistakes git commit --amend # fix last commit git reset --soft HEAD~1 # undo commit but keep changes git clean -fd # remove untracked files (careful!)
visual tools that saved my life 🙏
- VS Code Git integration (omg the colored lines are so helpful!)
- GitKraken (the graph view finally made branching click for me)
- GitHub Desktop (when i just can't with the command line)
when i first started, i thought git and github were the same thing... jacob had to explain that github is
like instagram for code, and git is like... the camera? idk the metaphor got weird 😂
my git workflow now! 🎯
- git pull on main to get latest changes
- create new branch for my feature
- commit small changes often (with good messages!)
- push branch and create PR
- fix code review comments
- merge and celebrate! 🎉
biggest lesson: git is actually super forgiving! almost everything can be undone (except when it can't...
always make backups of important stuff!)
resources that helped me learn! 📚
- Oh Sh*t, Git!? (website for when things go wrong)
- Git Branching Game (makes learning branches fun!)
- GitHub Learning Lab (interactive tutorials)
- jacob's infinite patience with my git questions 🙏
Comments