GitHub Ultimate Guide
Git is how you save your work in the cloud. Every change you make gets tracked, so you can always go back if something breaks. GitHub is where that work lives online—it's like Google Drive for code, but built for collaboration.
# The Scene
GitHub isn't just a website—it's where the world builds software. Over 100 million developers use it. Every major open-source project lives there. And if you want to work in tech, you need to understand it fluently.
But first, let's clear up the confusion everyone has at the start: Git and GitHub are not the same thing.
Think of Git as the engine and GitHub as the garage where you park your car so others can see it. Git does the version control locally. GitHub stores it in the cloud and adds collaboration features on top.
The GitHub Ecosystem
GitHub is more than code storage. It's a complete development platform. Here's what you get:
Your project's home. All code, history, and collaboration in one place. Public repos are free forever. Private repos free for individuals.
Track bugs, feature requests, and tasks. Kanban boards, milestones, and assignments. Free project management built into your repo.
Propose changes, get code review, discuss before merging. The heart of collaborative software development.
Automated workflows. Run tests, deploy code, check quality—all triggered by Git events. 2000 free minutes/month.
Host static websites directly from your repo. Perfect for portfolios, documentation, and project landing pages. 100% free.
AI that writes code with you. Autocompletes functions, explains code, generates tests. $10/month but free for students.
# Core Concepts
Before touching any commands, you need to understand six concepts. These are the building blocks of everything in Git and GitHub.
Repository
Your project's home
A repository (or "repo") is a folder that Git tracks. It contains all your
project files plus a hidden .git folder that stores the entire
history. One project = one repository.
my-project/ ├── .git/ <-- Git's brain (don't touch) ├── src/ │ └── app.js ├── README.md └── package.json
Commit
A snapshot in time
A commit is a saved checkpoint. It captures the state of all tracked files at that moment. Each commit has a unique ID, a message describing the change, and a link to the previous commit.
commit a1b2c3d
Author: you
Date: Jan 21, 2026
Add login functionalityBranch
Parallel universes for your code
A branch is an independent line of development. Create one to work on a feature
without affecting the main code. When done, merge it back. The default branch
is usually called main or master.
main: A---B---C---F
\ /
feature: D---EMerge
Combining branches
Merging takes changes from one branch and applies them to another. If both branches changed the same lines, you get a "merge conflict" that you'll need to resolve manually.
git checkout main git merge feature # feature's changes now in main
Pull Request
GITHUB FEATUREProposing changes for review
A Pull Request (PR) is a GitHub feature that lets you propose merging your branch into another. Teammates review the code, leave comments, request changes, and approve before merging. It's where collaboration happens.
Fork
Your copy of someone else's repo
Forking creates a complete copy of a repository in your account. You can modify your fork freely without affecting the original. Used for contributing to projects you don't have write access to.
original/repo → your-username/repo (read only) (full control)
How It All Connects
# Getting Started
Let's get you from zero to your first push. This takes about 15 minutes and you'll have a working GitHub setup for life.
Create Your GitHub Account
Your username becomes your identity. Choose wisely—employers will see it.
Install Git
Git is the command-line tool that does the actual version control. You need it installed locally.
Configure Git
Tell Git who you are. This info appears in every commit you make. Use the same email as your GitHub account.
Set Up SSH Key (Recommended)
SSH keys let you authenticate to GitHub without typing your password every time. This is the professional way to connect.
Create Your First Repository
Let's create a repo on GitHub, clone it locally, make a change, and push it back. This is the core workflow you'll use forever.
# Daily Workflow
These are the commands you'll use 90% of the time. Master these and you're set for most development work.
git status VERY FREQUENTShows what's changed, what's staged, and what branch you're on. Run this constantly.
$ git status
On branch main
Changes not staged for commit:
modified: src/app.js
Untracked files:
src/utils.jsgit add VERY FREQUENTStages changes for commit. Add specific files or all changes.
$ git add src/app.js # Stage one file $ git add . # Stage all changes $ git add src/ # Stage a folder
git commit VERY FREQUENTSaves staged changes as a snapshot with a message describing what changed.
$ git commit -m "Add login validation" $ git commit -am "Fix typo" # add + commit
git push FREQUENTUploads your commits to GitHub. Others can now see your changes.
$ git push # Push current branch $ git push -u origin main # First push sets upstream
git pull FREQUENTDownloads and merges changes from GitHub. Do this before starting work.
$ git pull # Get latest changes $ git pull origin main # Pull specific branch
git branch REGULARLists, creates, or deletes branches. Essential for feature work.
$ git branch # List branches $ git branch feature-login # Create branch $ git branch -d old-branch # Delete branch
git switch / checkout REGULARChanges your current branch. switch is the modern command.
$ git switch main # Switch to main $ git switch -c new-feature # Create and switch $ git checkout feature-x # Old way (still works)
git merge REGULARCombines another branch into your current branch.
$ git switch main # Go to main $ git merge feature-login # Merge feature into main
git log OCCASIONALShows commit history. Useful for understanding what changed and when.
$ git log --oneline # Compact view $ git log -5 # Last 5 commits $ git log --graph # Visual branch tree
git diff OCCASIONALShows what's changed in files. Review before committing.
$ git diff # Unstaged changes $ git diff --staged # Staged changes $ git diff main feature # Between branches
# Collaboration
Working with others is where Git and GitHub really shine. This section covers the workflows that teams use to build software together.
Forking & Contributing
Want to contribute to a project you don't own? Fork it first. This is how open source works.
Issues
Issues are GitHub's bug tracker and feature request system. They're also great for discussions and documentation.
Include: what you expected, what happened, steps to reproduce, environment info.
Describe the problem you're solving, not just the solution you want.
Use Fixes #123 in commit messages to auto-close issues when merged.
Pull Request Workflow ESSENTIAL SKILL
Pull Requests are how professional teams collaborate. Every feature, bug fix, and change goes through this process.
Create a Branch
Never work directly on main. Always create a feature branch.
git switch -c feature/user-authMake Your Changes
Write code, commit often with clear messages. Keep commits focused.
git commit -m "Add password validation"Push Your Branch
Upload your branch to GitHub. First push uses -u flag.
git push -u origin feature/user-authOpen Pull Request
On GitHub, click "Compare & pull request". Write a clear description of what changed and why.
Code Review
Teammates review your code, leave comments, request changes. Respond thoughtfully.
Address Feedback
Make requested changes, push new commits. They appear in the same PR.
git commit -m "Fix: use bcrypt for hashing"Merge & Cleanup
After approval, merge the PR. Delete the branch. Pull latest main locally.
Merge Conflicts DON'T PANIC
Conflicts happen when two people change the same lines. Git can't decide which version to keep, so you have to help.
# Advanced Concepts
Once you're comfortable with the basics, these features will level up your Git and GitHub game.
GitHub Actions
CI/CDAutomated workflows that run on Git events. Run tests on every push, deploy on merge, check code quality automatically.
name: Run Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm install
- run: npm testGitHub Pages
FREE HOSTINGHost static websites directly from your repository. Perfect for portfolios, documentation, and project landing pages.
username.github.io/repo-name.Branch Protection
SAFETYRules that prevent accidental pushes to important branches. Require PR reviews, passing tests, or specific approvers.
GitHub CLI (gh)
POWER USEROfficial command-line tool for GitHub. Create PRs, manage issues, trigger workflows—all from your terminal.
$ brew install gh # Install
$ gh auth login # Authenticate
$ gh pr create # Create PR
$ gh pr checkout 123 # Checkout a PR
$ gh issue list # View issues.gitignore
ESSENTIALTells Git which files to ignore. Never commit node_modules, .env files, build outputs, or OS files.
# Dependencies
node_modules/
# Environment
.env
.env.local
# Build output
dist/
build/
# OS files
.DS_Store
Thumbs.dbREADME.md
FIRST IMPRESSIONYour project's front door. Displayed on the repo homepage. A good README makes the difference between adoption and abandonment.
# Pro Tips
Write good commit messages
Use imperative mood: "Add login" not "Added login". First line under 50 chars. Explain why, not what (the diff shows what).
Commit often, push regularly
Small, focused commits are easier to review and revert. Push daily minimum—your laptop could die tomorrow.
Never commit secrets
API keys, passwords, .env files—if it's sensitive, it goes in .gitignore. Once committed, it's in history forever (even if you delete it).
Use branches for everything
Even solo projects benefit from branches. It keeps main clean and gives you freedom to experiment without risk.
Review your own PR first
Before requesting review, look at your own diff on GitHub. You'll catch mistakes you missed in your editor.
Learn keyboard shortcuts
Press ? on any GitHub page to see shortcuts. t opens file finder. . opens VS Code in browser.