What is the difference between . and * in “git add”?
git add command, I use
* to add all the files in the working directory.
What is the difference between them?
One Solution collect form web for “What is the difference between . and * in “git add”?”
Neither of these are
. is a representation of the current working directory. So if you say, for example,
git add ., you really mean “git, please add the current working directory to the staging area for my current change”. Most other commands treat
. the same way:
cd . will move you nowhere.
*, on the other hand, is a shell glob. This particular glob is exapanded to “all files”. So when you say
git add *, what first happens is that your shell (the program you’re typing commands into) expands it to be every file and directory in your current location, then
git gets that list. So the
git command doesn’t even see the
* at all – it just sees that you wanted to
add everything in your current working directory.
The net effect is basically the same: everything in the working directory gets added. The way it happens, though, is totally different.
git add . is probably what you wanted to do – what it does under the hood is nearer to your intent.