Difference between add . | add * | add -u | add -A/add–all

In this post I wish to document the correct and concise difference between these 4 types of git command to add files to stage them for a commit to your online repository.

1. git add . v/s git add * 

add * adds all the files in the current directory, and stages them for a commit, except the ones that begin with a dot. Files beginning with a . are hidden for add *n.
On the other hand, git add . will add all the files, folders, sub-folders to the staging area along with the ones that begin with a ‘.’ .
I also read that * is not a part of git. It is a wildcard, interpreted by the shell. * expands to all the files in the current directory. However, add . refers to the current directory itself and git add . will add all the files in that directory, including the files beginning with a dot.
http://stackoverflow.com/questions/16969768/what-does-git-add-git-add-single-dot-command-do
http://stackoverflow.com/questions/26042390/git-add-asterisk-vs-git-add-period

NOTE: Both add * and add . don’t add the removed files for commiting.

2. git add *  v/s  git add -A/–all  v/s  git add -u

YfLUZ

This table depicts graphically the difference between these 3 implements of git add.

add . or add * indexes all the new and modified files and stages them for a commit, except for the files that have been removed.

add -u stages all modified and removed files for a commit, except for the new files created. It does not add any new files, it only stages changes to the files that have been tracked before.

add -A or add –all is a combination of both add . & add -u. It will add all new files, modified files and removed files, for staging.

http://stackoverflow.com/questions/572549/difference-between-git-add-a-and-git-add
Hope I have been able to make the difference between these 4 kinds of add commands clear.

– jigsaw

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s