About this question
For example, how could I commit only 15 lines out of 30 lines that have been changed in a file?
The command git add [--all|-A] appears to be identical to git add .. Is this correct? If not, how do they differ?
For example, how could I commit only 15 lines out of 30 lines that have been changed in a file?
The command git add [--all|-A] appears to be identical to git add .. Is this correct? If not, how do they differ?
Log in to share your answer and help other learners.
Log in to answerBest Answer · By JanBask Salesforce Expert
Answered on Feb 23, 2021
git add -A : It will stage all changes
git add . : It will stage new files and modifications, without deletions
git add -u: It will stage modifications and deletions, without new files
Let me elaborate it a bit:
git add -A is equivalent to git add . and git add -u
git add . will look at the working tree. Then it will add all those paths to the staged changes if they are either changed or are new and not ignored. But it will not stage any 'rm' actions.
git add -u will look at all the already tracked files. Then it will stage the changes to those files if they are different or if they have been removed. It will not add any new files, it will only stage changes to already tracked files.
Here's a practical explanation to help you understand the differences better:
git init
echo Change me > change-me
echo Delete me > delete-me
git add change-me delete-me
git commit -m initial
echo OK >> change-me
rm delete-me
echo Add me > add-me
git status
#Changed but not updated:
#modified: change-me
#deleted: delete-me
#Untracked files:
#add-me
git add .
git status
#Changes to be committed:
#new file: add-me
#modified: change-me
#Changed but not updated:
#deleted: delete-me
git reset
git add -u
git status
#Changes to be committed:
#modified: change-me
#deleted: delete-me
#Untracked files:
#add-me
git reset
git add -A
git status
#Changes to be committed:
#new file: add-me
#modified: change-me
#deleted: delete-me
Note: For Git version 2.x, output for git add . and git status will be different.
Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.
Step-by-step Salesforce guides from industry experts
Common Salesforce interview questions, answered
Guides, tips and career advice on Salesforce from JanBask experts.
Salesforce Entry-Level Salesforce Admin Salary: What Can You Expect to Earn?
Curious what an entry-level Salesforce Admin actually earns? See real salary benchmarks by experience and location, plus how to…
Salesforce Senior Salesforce Admin Salary: Salary Range, Factors & Career Growth
What does a senior Salesforce administrator actually earn? See real salary ranges, the skills that boost pay, and how to move up…
Salesforce Cost for Salesforce Certification: Exam Fees by Type, Retakes & Hidden Costs
Salesforce certification exam fees run $75 to $4,500, and most cost $200. See cost by role, retakes, taxes, discounts, and…
Salesforce Salesforce Admin Certification Cost 2026: Exam Fees, Retake & Other Expenses
Learn the Salesforce Admin certification cost in 2026, including the exam fee, retake cost, taxes, discounts, preparation…