git add
Stage changes — prepare them for the next commit
Practical example
git add src/index.ts # stage a single file git add -p # stage interactively, hunk by hunk git add . # stage all changes in current dir
Command overview & how it works
Moves changes from the working directory into the staging area (also called the index). Only changes that have been staged will be included in the next git commit. Use git add <file> to stage a single file, git add . to stage all changes in the current directory (including new files), or git add -p to stage interactively — this shows each hunk of changes and lets you decide whether to stage it, a powerful way to create clean, focused commits. Use git add -A to stage all changes across the entire repository (not just the current directory). Staging is what makes Git different from older version control systems — it gives you fine-grained control over what goes into each commit without needing to commit everything at once.
Get the complete offline Git Field Guide
The 97-page PDF + ePub course — ₹499. Read this command, offline.
Practical tips
- Use git add -p to review each hunk interactively and build clean, focused commits.
- Use git add -A to stage deletions across the whole repository, not just new and modified files in the current directory.
- Review what is staged with git diff --staged before you commit.
Deep-dive guides & tutorials
In-depth walkthroughs and practical scenarios related to git add
- Guide
How to Install Git on Windows, macOS, and Linux
A step-by-step setup guide covering every major platform, from Homebrew and Winget to package managers, plus verifying your install and configuring your identity.
7 min readRead guide - Tutorial
Git Basics Every Developer Should Know
Understand the core concepts — repositories, commits, branches, and remotes — before diving into the command line.
6 min readRead guide - Guide
How to Write Better Git Commit Messages
A practical guide to writing clear, conventional commit messages that make your project history readable and your team more productive.
6 min readRead guide
Related commands
More from Working with Changes