MASTER GIT & GITHUB

GitHub Ultimate Guide

UPDATED: Jan 2026 All Platforms Git / GitHub / Collaboration

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.

$ cat /var/log/github/why-this-matters.md

# 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.

WHY GITHUB?
Version Control Never lose work. Track every change. Undo anything.
Collaboration Work with anyone, anywhere. Review each other's code.
Portfolio Your GitHub profile is your developer resume.
Industry Standard Required for every software job. No exceptions.

But first, let's clear up the confusion everyone has at the start: Git and GitHub are not the same thing.

ASPECT GIT GITHUB
What is it? Software on your computer Website / Cloud service
Purpose Track changes locally Store & share remotely
Works offline? Yes No
Created by Linus Torvalds (2005) GitHub Inc (2008)
Alternatives None (standard) GitLab, Bitbucket

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.

[G] The GitHub Ecosystem

GitHub is more than code storage. It's a complete development platform. Here's what you get:

Repositories Core Feature

Your project's home. All code, history, and collaboration in one place. Public repos are free forever. Private repos free for individuals.

Issues & Projects Project Management

Track bugs, feature requests, and tasks. Kanban boards, milestones, and assignments. Free project management built into your repo.

Pull Requests Collaboration

Propose changes, get code review, discuss before merging. The heart of collaborative software development.

Actions CI/CD

Automated workflows. Run tests, deploy code, check quality—all triggered by Git events. 2000 free minutes/month.

Pages Free Hosting

Host static websites directly from your repo. Perfect for portfolios, documentation, and project landing pages. 100% free.

Copilot AI Pair Programming

AI that writes code with you. Autocompletes functions, explains code, generates tests. $10/month but free for students.

$ man git-concepts

# Core Concepts

Before touching any commands, you need to understand six concepts. These are the building blocks of everything in Git and GitHub.

[R]

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
[C]

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 functionality
[B]

Branch

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---E
[M]

Merge

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
[F]

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

YOUR COMPUTER
Working Directory ↓ git add Staging Area ↓ git commit Local Repository
git push → ← git pull
GITHUB
Remote Repository Issues Pull Requests Actions
$ ./setup.sh --github-quickstart

# 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.

01

Create Your GitHub Account

Your username becomes your identity. Choose wisely—employers will see it.

github-signup
# 1. Go to github.com and sign up
$ open https://github.com/signup
# Username tips:
# - Use your real name or a professional handle
# - Avoid numbers and underscores if possible
# - This will be in URLs: github.com/YOUR-USERNAME
# Good: johnsmith, jane-doe, jsmith
# Avoid: xX_john_smith_123_Xx
Profile tip: Add a profile photo, bio, and location. Fill out your README (it shows on your profile page).
02

Install Git

Git is the command-line tool that does the actual version control. You need it installed locally.

macOS
# Git comes with Xcode Command Line Tools
$ xcode-select --install
# Or install via Homebrew
$ brew install git
# Verify installation
$ git --version
git version 2.43.0
Windows
# Download Git for Windows
$ open https://git-scm.com/download/win
# Run installer, use defaults
# This also installs Git Bash
# Verify in Git Bash or PowerShell
$ git --version
Linux
# Debian/Ubuntu
$ sudo apt update && sudo apt install git
# Fedora
$ sudo dnf install git
# Arch
$ sudo pacman -S git
03

Configure Git

Tell Git who you are. This info appears in every commit you make. Use the same email as your GitHub account.

git-config
# Set your name (appears in commits)
$ git config --global user.name "Your Name"
# Set your email (must match GitHub account)
$ git config --global user.email "you@example.com"
# Set default branch name to 'main'
$ git config --global init.defaultBranch main
# Verify your settings
$ git config --list
user.name=Your Name
user.email=you@example.com
init.defaultbranch=main
04

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.

ssh-setup
# 1. Generate a new SSH key
$ ssh-keygen -t ed25519 -C "you@example.com"
Generating public/private ed25519 key pair.
Enter file: [press Enter for default]
Enter passphrase: [optional but recommended]
# 2. Start the SSH agent
$ eval "$(ssh-agent -s)"
Agent pid 12345
# 3. Add your key to the agent
$ ssh-add ~/.ssh/id_ed25519
# 4. Copy your public key
$ cat ~/.ssh/id_ed25519.pub
ssh-ed25519 AAAA... you@example.com
# 5. Add to GitHub: Settings → SSH Keys → New
$ open https://github.com/settings/keys
# 6. Test the connection
$ ssh -T git@github.com
Hi username! You've successfully authenticated.
Why SSH? HTTPS requires tokens that expire. SSH keys are permanent and more secure. Set it up once, never think about it again.
05

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.

first-repo
# 1. Create repo on GitHub (click "New" button)
$ open https://github.com/new
# Name it "hello-github", add a README, create
# 2. Clone to your computer (use SSH URL)
$ git clone git@github.com:YOUR-USERNAME/hello-github.git
Cloning into 'hello-github'...
# 3. Enter the project folder
$ cd hello-github
# 4. Make a change
$ echo "My first edit!" >> README.md
# 5. Stage the change
$ git add README.md
# 6. Commit with a message
$ git commit -m "Add first edit to README"
[main abc1234] Add first edit to README
1 file changed, 1 insertion(+)
# 7. Push to GitHub
$ git push
Enumerating objects: 5, done.
Writing objects: 100% (3/3), done.
Success! Refresh your GitHub repo page. You'll see your commit with the message you wrote. That's the entire Git/GitHub cycle in action.
$ git --help everyday

# 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 FREQUENT

Shows 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.js
git add VERY FREQUENT

Stages 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 FREQUENT

Saves 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 FREQUENT

Uploads 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 FREQUENT

Downloads and merges changes from GitHub. Do this before starting work.

$ git pull                   # Get latest changes
$ git pull origin main       # Pull specific branch
git branch REGULAR

Lists, 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 REGULAR

Changes 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 REGULAR

Combines another branch into your current branch.

$ git switch main          # Go to main
$ git merge feature-login  # Merge feature into main
git log OCCASIONAL

Shows 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 OCCASIONAL

Shows what's changed in files. Review before committing.

$ git diff                 # Unstaged changes
$ git diff --staged        # Staged changes
$ git diff main feature    # Between branches
TYPICAL DAILY WORKFLOW
# Start of day: get latest changes
$ git pull
# Create branch for your task
$ git switch -c feature/add-search
# Do work... then save progress
$ git status # See what changed
$ git add .
$ git commit -m "Add search bar component"
# Push branch to GitHub
$ git push -u origin feature/add-search
# Open Pull Request on GitHub...
# After approval, merge and cleanup
$ git switch main
$ git pull
$ git branch -d feature/add-search
$ gh pr create --help

# Collaboration

Working with others is where Git and GitHub really shine. This section covers the workflows that teams use to build software together.

[F] Forking & Contributing

Want to contribute to a project you don't own? Fork it first. This is how open source works.

fork-workflow
# 1. Fork on GitHub (click "Fork" button)
# Creates: github.com/YOUR-NAME/project
# 2. Clone YOUR fork
$ git clone git@github.com:YOUR-NAME/project.git
# 3. Add original repo as "upstream"
$ git remote add upstream git@github.com:ORIGINAL/project.git
# 4. Keep your fork updated
$ git fetch upstream
$ git merge upstream/main
# 5. Create branch, make changes, push to YOUR fork
# 6. Open PR from your fork to original repo

[I] Issues

Issues are GitHub's bug tracker and feature request system. They're also great for discussions and documentation.

BUG REPORT

Include: what you expected, what happened, steps to reproduce, environment info.

FEATURE REQUEST

Describe the problem you're solving, not just the solution you want.

REFERENCE IN COMMITS

Use Fixes #123 in commit messages to auto-close issues when merged.

[P] Pull Request Workflow ESSENTIAL SKILL

Pull Requests are how professional teams collaborate. Every feature, bug fix, and change goes through this process.

1

Create a Branch

Never work directly on main. Always create a feature branch.

git switch -c feature/user-auth
2

Make Your Changes

Write code, commit often with clear messages. Keep commits focused.

git commit -m "Add password validation"
3

Push Your Branch

Upload your branch to GitHub. First push uses -u flag.

git push -u origin feature/user-auth
4

Open Pull Request

On GitHub, click "Compare & pull request". Write a clear description of what changed and why.

5

Code Review

Teammates review your code, leave comments, request changes. Respond thoughtfully.

6

Address Feedback

Make requested changes, push new commits. They appear in the same PR.

git commit -m "Fix: use bcrypt for hashing"
7

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.

conflict-resolution
# You'll see this in the file:
<<<<<<< HEAD
const greeting = "Hello World";
=======
const greeting = "Hi there";
>>>>>>> feature-branch
# Fix by:
# 1. Decide which version to keep (or combine)
# 2. Remove the <<<, ===, >>> markers
# 3. Save the file
# Then complete the merge:
$ git add .
$ git commit -m "Resolve merge conflict in greeting"
Pro tip: Use VS Code or your IDE's built-in merge conflict resolver. It shows both versions side by side with buttons to accept either change.
$ man git-advanced

# Advanced Concepts

Once you're comfortable with the basics, these features will level up your Git and GitHub game.

[A]

GitHub Actions

CI/CD

Automated workflows that run on Git events. Run tests on every push, deploy on merge, check code quality automatically.

Run tests Deploy to production Lint code Build releases
.github/workflows/test.yml
name: Run Tests
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm install
      - run: npm test
[P]

GitHub Pages

FREE HOSTING

Host static websites directly from your repository. Perfect for portfolios, documentation, and project landing pages.

Portfolio sites Documentation Project demos
Enable: Repo Settings → Pages → Select branch (usually main) and folder (/ or /docs). Your site appears at username.github.io/repo-name.
[B]

Branch Protection

SAFETY

Rules that prevent accidental pushes to important branches. Require PR reviews, passing tests, or specific approvers.

Require PR reviews Block force pushes Require status checks
Enable: Repo Settings → Branches → Add rule for "main". At minimum, enable "Require pull request reviews".
[G]

GitHub CLI (gh)

POWER USER

Official 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
[I]

.gitignore

ESSENTIAL

Tells Git which files to ignore. Never commit node_modules, .env files, build outputs, or OS files.

.gitignore
# Dependencies
node_modules/

# Environment
.env
.env.local

# Build output
dist/
build/

# OS files
.DS_Store
Thumbs.db
Tip: Use gitignore.io to generate .gitignore files for any tech stack.
[R]

README.md

FIRST IMPRESSION

Your project's front door. Displayed on the repo homepage. A good README makes the difference between adoption and abandonment.

Project description Installation steps Usage examples Contributing guide
Must have: What it does, how to install, how to use, how to contribute. Add screenshots or GIFs for visual projects.
$ cat ~/.gitconfig-tips

# Pro Tips

01

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).

02

Commit often, push regularly

Small, focused commits are easier to review and revert. Push daily minimum—your laptop could die tomorrow.

03

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).

04

Use branches for everything

Even solo projects benefit from branches. It keeps main clean and gives you freedom to experiment without risk.

05

Review your own PR first

Before requesting review, look at your own diff on GitHub. You'll catch mistakes you missed in your editor.

06

Learn keyboard shortcuts

Press ? on any GitHub page to see shortcuts. t opens file finder. . opens VS Code in browser.

Frequently Asked Questions