These are the commands you'll use every single day. Master these and you're 80% there.
1. Edit files 2. git add <file> # Stage changes 3. git commit -m "..." # Save a snapshot 4. git push # Upload to GitHub
# Check what changed git status # See history git log --oneline # Stage files git add index.html # one file git add . # all changes in current dir # Commit git commit -m "Add login page" git commit -am "Fix typo" # add + commit tracked files # Push & pull git push origin main # upload changes git pull origin main # download changes # Undo last commit (keep changes) git reset --soft HEAD~1 # Discard changes in a file git checkout -- filename.html # See changes not yet staged git diff
# Bad git commit -m "fix" git commit -m "stuff" # Good git commit -m "Fix login redirect after password reset" git commit -m "Add dark mode toggle to navbar" git commit -m "Refactor: extract validation into helpers.js"