Skip to content

Gondew Life

AI·ML 개발, 맥 생산성, 웹 디자인 기록

Menu
  • English
  • 한국어
  • about
  • Contact
  • Privacy
Menu

Git vs GitHub Explained: Core Differences, Essential Commands, and PR Workflows

Dec 3, 20262026년 12월 04일
이 글은 한국어로도 읽을 수 있습니다.한국어 버전으로 읽기 →

One of the most common early stumbling blocks in software development is confusing Git with GitHub. Because their names sound almost identical, beginners often assume they are the same product. In reality, Git is a local distributed version control system running on your machine, while GitHub is a cloud hosting platform built around Git repositories for collaboration, code review, and CI/CD.

This guide breaks down the exact differences between Git and GitHub, explains Git’s three local areas, walks through the 10 daily commands every developer relies on, and compares Merge, Squash, and Rebase strategies for real-world Pull Requests.

1. Git vs. GitHub at a Glance

Think of Git as the camera and local editing timeline on your laptop, and GitHub as the shared cloud gallery where teammates review your snapshots, open discussions, and trigger automated builds. You can commit, branch, and roll back code with Git offline on an airplane; you need GitHub (or another remote host) when you want remote backup, Pull Requests, Issues, or GitHub Actions.

AspectGitGitHub
What it isDistributed Version Control System (VCS CLI/software)Cloud platform hosting Git repositories
Where it runsLocally on your computerIn the cloud (Web UI, API, remote servers)
Internet requiredNo (full commits, branches, diffs work offline)Yes (push/pull, PRs, Issues, Actions)
Core strengthsFast snapshots, branching & merging, history rollbackRemote backup, Pull Request review, CI/CD, access control
AlternativesMercurial, Subversion (SVN)GitLab, Bitbucket, Codeberg, Gitea

2. Understanding Git’s Three Local Areas

Most Git confusion disappears once you picture the three local stages every file moves through before reaching GitHub:

  1. Working Directory: The files you actively edit in your IDE or editor. Changes here are untracked or unstaged until you select them.
  2. Staging Area (Index): A curated checklist of exact changes you want in the next snapshot. You move changes here with git add.
  3. Local Repository (.git): The permanent local commit history created by git commit, where every commit gets an immutable SHA hash.

GitHub sits one layer beyond as your Remote Repository: git push uploads local commits to GitHub, while git fetch and git pull bring teammates’ commits back down.

3. The 10 Essential Git Commands for Daily Work

# 1) Initialize a new repo or clone an existing one over SSH
git init
git clone git@github.com:username/repo.git

# 2) Inspect modified files and line-level diffs
git status
git diff

# 3) Stage specific files and record an atomic commit
git add src/app.py
git commit -m "feat: add user profile caching"

# 4) Create and switch to a feature branch (modern replacement for checkout)
git switch -c feat/login-page

# 5) Sync with GitHub and push your branch
git fetch origin
git pull origin main
git push -u origin feat/login-page

# 6) View a clean, compact commit graph
git log --oneline --graph --all -n 15

Prefer modern git switch (for changing branches) and git restore (for discarding file edits) over the overloaded git checkout command—splitting those two responsibilities prevents accidental data loss.

4. Pull Request Merge Strategies: Merge vs. Squash vs. Rebase

StrategyHow it worksBest forWatch out for
Merge CommitPreserves every branch commit and adds a two-parent merge commitAudit-heavy teams needing exact branch topologyNoisy commit graphs on high-velocity repos
Squash and MergeCompresses all feature-branch commits into one clean commit on mainMost product teams wanting readable feature-level historyGranular WIP commits live only in the PR log
Rebase and MergeReplays branch commits linearly on top of latest mainSmall, tightly curated commit seriesNever force-push rebased history on shared branches without --force-with-lease

5. Four Common Mistakes and How to Fix Them Safely

1) Accidentally committing .env or secrets

Adding .env to .gitignore after it was already committed does not untrack it. Remove it from Git’s index while keeping your local copy—and if it was already pushed to GitHub, rotate and revoke every exposed key immediately:

git rm --cached .env
echo ".env" >> .gitignore
git commit -m "chore: untrack .env file"

2) Fixing a typo or forgotten file in your last local commit

# Safe before pushing to a shared branch
git add missed_file.py
git commit --amend -m "feat: include input validation"

3) Switching branches mid-task without committing half-finished work

git stash push -m "wip: sidebar filter"
git switch main
# Later, return and restore your changes
git switch feat/sidebar
git stash pop

4) Undoing commits: git reset vs. git revert

Use git reset --soft HEAD~1 only for unpublished local commits. Once a commit is on a shared branch like main, always use git revert <commit-hash>, which creates a safe inverse commit without rewriting teammates’ history.

FAQ

Do solo developers still need both Git and GitHub?

Yes. Git lets you experiment fearlessly on throwaway branches and roll back mistakes in seconds, while private GitHub repositories give you free cloud backup and seamless machine-to-machine syncing.

Why choose SSH keys over HTTPS for GitHub?

GitHub disabled password authentication over HTTPS. Setting up a single ed25519 SSH key once lets you push and pull securely without repeatedly managing expiring Personal Access Tokens.

글 탐색

← [2026 Guide] Claude Code Setup vs OpenAI Codex vs Google Antigravity: AI Coding Agent Plugins & Skills Compared
Migrating WordPress from PHP 7.4 to 8.4: Fixing Fatal sprintf() Bugs & Cutting Mobile LCP from 4.3s to 0.8s →
© 2026 Gondew Life | Powered by Minimalist Blog WordPress Theme