Difference between “add -A”, “add -u”, “add .” , and “add *”
Last Updated :
03 Jun, 2024
git add -A or git add –all :
What it does is it’s going to stage all the changes, all the modified, deleted, and new files, and the dot file in the entire working tree.

git add -A
So, you can say it does the entire working tree it means that if you are in my subdirectory and you can execute
git add -A
It will stage all the changes no matter what subdirectory you are in.

git add -A
We can also use
git add -A
to stage all the changes in a particular directory.
Note –
git add -A
It is the default behavior of git add. so, I can leave off the
-A
then also it is going to do the exact same thing for all the above 3 cases. Now this behavior is actually new to git version 2. In git version 1 if you left off
-A
it would ignore the deleted files. Now, if you still want that git version 1 functionality just do
git add –no-all
or
git add –ignore-removal
.
git add -u or git add –update :
It add all the modified and deleted files but not any untracked files and it does this for the entire tree.

git add -u
So, if you specify a directory then it would stage all the modified and deleted files in that subdirectory but will not stage any untracked files without affecting the changes in its parent directory.

git add -u newdir
git add .
This specific command will stage all the changes no matter what type it is whether it be untracked files or deleted files or modified files.

git add
Now, it might seem like it does the exact same as
git add -A
but it looks the same as long as you are in the top directory. So let’s see how this is different. If you are in your top directory then
git add -A
and
git add .
are the exact same.

git add
So, you can see in the above image doing
git add .
in the subdirectory will stage all changes in that subdirectory but will not affect its parent directory. So the main difference between
git add .
and
git add -A
is that in
git add -A
no matter from where you execute this command it will stage everything whether it be the subdirectory or the parent directory but
git add .
stages only the changes in the current directory and not it’s parent directory.
git add *
Now, you can see many students using this command and you can personally avoid this command and advice you the same, this is because
*
is a shell command and it’s not something that git specifically knows how to use it will just take everything that’s aster.

ls *
As shown below when you will execute the command
git add *
gives a very unexpected result because it couldn’t see the deleted files but one deleted file got added to the staging area and this deleted file didn’t and the hidden file didn’t get at it.
Similar Reads
Difference between âgit add -Aâ and âgit addâ
When working with Git, the git add command is used to move changes from your working directory to the staging area. However, there are different options and flags that can be used with git add, such as -A, which might lead to some confusion. In this article, we'll explore the differences between git
2 min read
Difference Between Ash and Bash
There are various shells that offer different features and better syntax than each other in the UNIX operating system. Ash and Bash are two common shells for this operating system. What is Ash? Ash, originally known as Almquist Shell, also known by other names such as "a Shell" or "Sh" is a lightwei
2 min read
Difference between Serial Adder and Parallel Adder
A Addition is a fundamental operation in the digital electronics and it is used in a wide range of a applications such as the arithmetic, data processing and control systems. There are the two main types of a adders used in digital circuits are Serial Adder and a Parallel Adder. Understanding the di
7 min read
Difference between ++*p, *p++ and *++p
Predict the output of following C programs. C/C++ Code // PROGRAM 1 #include <stdio.h> int main(void) { int arr[] = {10, 20}; int *p = arr; ++*p; printf("arr[0] = %d, arr[1] = %d, *p = %d", arr[0], arr[1], *p); return 0; } C/C++ Code // PROGRAM 2 #include <stdio.h> int main(voi
2 min read
Difference Between '+' and 'append' in Python
+ Operator creates a new sequence by concatenating two existing sequences and .append() method (available for lists) modifies the existing list in place by adding one item at the end. In this article we are going to compare '+' operator and append in Python. + Operator in Python+ operator is typical
3 min read
Difference between AS Override and Allowas In
1. AS Override : Its feature allows a provider edge (PE) router to change private autonomous system used by customer edge (CE) device on an external BGP session running on a VPN routing and forwarding access link. The private AS number is changed to PEAS number. 2. Allowas In : This feature allows f
2 min read
Difference between 3-address instruction and 2-address instructions
In computer architecture, instructions are the basic building blocks of execution that manually inform records how records is processed through the CPU. Three-operand instructions and two-address instructions differ in how they specify operands for acting operations, such as addition or multiplicati
8 min read
Difference between 2-address instruction and 1-address instructions
When we convert a High-level language into a low-level language so that a computer can understand the program we require a compiler. The compiler converts programming statements into binary instructions. Instructions are nothing but a group of bits that instruct the computer to perform some operatio
5 min read
Similarities and Differences between Ruby and C++
There are many similarities between C++ and Ruby, some of them are: Just like C++, in Ruby⦠As in C++, public, private, and protected works similarly in Ruby also .Inheritance syntax is still only one character, but itâs < instead of : in Ruby.The way ânamespaceâ is used in C++, in the similar wa
3 min read
Difference between Macro and Procedure
While programming, particularly in languages such as C or assembly, you come across such terms as macro and procedure (or function). The two are vital that assist in the creation of good, easy to manage code but are not used in the same manner and are not the same. You may come across macros and pro
6 min read