Table of Contents
Most people’s first question about Git is: “Why do I need this?”
The answer is simple: with Git, you never have to name files final.docx, final_v2.docx, or final_FINAL_really.docx again. Every commit is a snapshot of your project at a specific point in time. You can go back to any version, see exactly what changed, and why. When collaborating with others, you stop worrying about accidentally overwriting each other’s work.
TL;DR
Git is a version control tool. GitHub is a cloud platform for hosting Git repositories. Master the “add → commit → push” cycle and you’ll handle 90% of everyday use cases.
Prerequisites
- Install Git from git-scm.com
- Create a GitHub account at github.com
- Access to a terminal (macOS Terminal, Windows PowerShell, or Git Bash)
After installation, run git --version in your terminal. Seeing a version number means you’re good to go.
Understanding the Three Working Areas
Git has three “working areas.” Get these straight and most commands will make sense:
Working Directory: Where you actually edit files — just your regular folder on disk.
Staging Area: A holding area for changes you’re about to commit. git add moves things here.
Repository: The permanent record of all your commits. git commit writes the staging area into the repository.
Step 1: Create Your First Repository
On GitHub, click the ”+” button in the top-right corner, select “New repository,” fill in the name, and click “Create repository.”
Then on your computer:
mkdir my-project
cd my-project
git init
git remote add origin https://github.com/your-username/my-project.git
Step 2: Make Your First Commit
echo "Hello, Git!" > README.md
git add README.md
git commit -m "Initial commit: add README"
git push -u origin main
The -u origin main flag sets the default push target. After this, just git push is enough.
Step 3: Use Branches to Experiment Safely
Think of branches as parallel universes. You make changes in a branch, confirm everything works, then merge it back into main. The main branch stays stable throughout.
git checkout -b feature/add-login
echo "Login page" > login.html
git add login.html
git commit -m "Add login page"
git checkout main
git merge feature/add-login
# Clean up after merging
git branch -d feature/add-login
Handling Merge Conflicts
If two branches modify the same line of the same file, Git can’t decide which version to keep and marks it as a conflict. The file will look like this:
<<<<<<< HEAD
This is the main branch version
=======
This is the feature branch version
>>>>>>> feature/add-login
Edit the file to keep what you want, remove the conflict markers, then git add and git commit to finish.
Useful Commands for Daily Use
git status # See which files have changes
git log --oneline # View commit history in brief
git show <hash> # Inspect a specific commit
Common Questions
Getting “permission denied” when pushing? This is usually an authentication issue. GitHub recommends using a Personal Access Token — generate one in your account settings and use it as your password when prompted.
Can I fix a commit message after committing?
If you haven’t pushed yet, git commit --amend lets you edit the last message. If you’ve already pushed, it’s better to leave it — rewriting history affects collaborators.
How do I tell Git to ignore certain files?
Create a .gitignore file in the project root and add the paths you want to skip, like node_modules/ or .env. GitHub provides templates for most languages.
References
Tags
Related Articles
GitHub Hot This Week #115: Desktop AI Agent, Ungoogled Chromium, CLI Framework, 3D Reconstruction
This week's GitHub trending: a desktop AI agent framework that controls GUI apps without APIs, an ungoogled Chromium fork, a one-decorator CLI conversion framework, a coding agent knowledge graph, and a real-time streaming 3D reconstruction model.
What Is Sup? An Async Video Tool for Replacing Informal Standups
Sup is a tool for async video standups — replace your daily five-minute synchronous check-in with a short recorded video each team member watches at their own time
GitHub Trending Week 113: Warp Goes Open Source, Agent Skills Standard, Codex CLI GA
Three big GitHub moments in early May 2026: Warp terminal goes open source (37K stars in days), GitHub Copilot launches the Agent Skills open standard, and Codex CLI hits general availability — the AI dev toolchain is consolidating fast.