Git — Add
Basic Add
# Add specific file
git add file.txt
# Add multiple files
git add file1.txt file2.txt
# Add all changes
git add .
# Add all files
git add -A
Add Pattern
# Add all .txt files
git add *.txt
# Add all files in directory
git add dir/
# Add all files except specific
git add .
git reset HEAD file.txt
Interactive Add
git add -p
This shows each change and lets you decide to stage it.
Check Staged Changes
# See what's staged
git status
# See staged changes
git diff --staged
# See all changes
git diff
Unstage Files
# Unstage specific file
git reset HEAD file.txt
# Unstage all
git reset HEAD
Mini Practice
- Add specific files
- Add all changes
- Use interactive add
- Check staged changes
Up Next
Continue with Commit — saving changes.
Related Topics
Frequently Asked Questions about Add
What is Add in Git?
Add is a fundamental concept in Git. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn Add?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Add.
Why is Add important in Git?
Add is essential for Git development. Understanding this concept will help you write better code and solve real-world problems more effectively.