What's the difference between. and * in "git add"?

and in the git add command I use . and * to add all files to the working directory.

What is the difference between the two?

+5
source share
1 answer

None of these git concepts:

. is a representation of the current working directory. So, if you say, for example, git add . , you really mean "git, add the current working directory to the staging area for my current change." Most other teams interpret . also: cd . will not move anywhere.

* , on the other hand, is a glob shell. This particular globe is exapanded for "all files." So when you say git add * , it first happens that your shell (the program you enter the commands into) expands it to be every file and directory in your current location, and then git gets that list. Thus, the git command does not see * at all - it just sees that you want to add everything in your current working directory.

The network effect is basically the same: everything in the working directory is added. However, how this happens is completely different. git add . probably what you wanted to do is what he does under the hood, closer to your intentions.

+6
source

All Articles