Difference between “git add -A” and “git add”
Git is a free and open-source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. It is basically, software for tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development.
It is massively used by programmers who work on projects in a team for the following purpose.
- Keep track of all files in a project.
- Record changes done in project files.
- Compare and analyze codes.
- Restore previous versions.
- Merge code from different systems of team members.
Here, we will discuss the working steps as follows.
We use various command while working with git, here’s the detailed explanation of the two commands we are often confused with i.e. “git add” and “git add -A”
“git add” places the modified version of the file from the working directory and places it into the staging area.
git add file_name_with_extension
git add readme.md
“git add -A” stages all the changes. It is equivalent to “git add -all” or “git add . , git add -u” combined. Here, we will understand the difference in both of them as follows.
- “git add .” stages new files and modifications, without deletions (on the current directory and its subdirectories).
- “git add -u” stages modifications and deletion without new files.
So, “git add -A” is a handy shortcut to both of those.
git add -A
git add -all
git add . git add -u
Implementation steps :
In short, we can say that “git add” is used to stage a specific file while “git add -A” stages all the modified files at once.
In the following screenshot, changes are made in the five files.
Now, to add a single file into the staging area, we use “git add file_name with the extension” as shown below.
To add multiple files into the staging area at once, we use “git add -A” as shown below.