Git Basics: What I Wish I Knew Day One! 🚀

Home | News | Portfolio | Downloads | Blog | Cool Links | Guestbook
Posted on March 1, 2024 by -intern
Tags: Git, Version Control, Learning, Tutorials

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 🤔

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! 🌳

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 🙏

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! 🎯

  1. git pull on main to get latest changes
  2. create new branch for my feature
  3. commit small changes often (with good messages!)
  4. push branch and create PR
  5. fix code review comments
  6. 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! 📚

Related Articles:

Comments

88x31 Button Powered By Verified
Hit Counter

© 2013-2024 ComputaCombinator. All rights reserved.
Best viewed in Internet Explorer 6.0 at 1024x768 resolution
Valid HTML!