What is the difference between . and * in “git add”?

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

What is the difference between them?

  • Git: track branch in submodule but commit in other submodule (possibly nested)
  • How to ignore files in Git merge?
  • What is wrong with this git smudge/clean filter?
  • npm error: cloning into bare repository + unable to find remote helper for https
  • Is there anything wrong with using git like this?
  • Git - nullSha1: contains entries pointing to null sha1
  • How can I move a set of commits from master to a separate branch?
  • Faster git clone
  • How to prevent git merge if current branch has uncommitted changes
  • is there any way how to tell git to ignore certain lines of a file?
  • Can't find local files after pushing new git branch
  • How to add git repo to working dir of a project
  • One Solution collect form web for “What is the difference between . and * in “git add”?”

    Neither of these are git concepts:

    . 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.

    Git Baby is a git and github fan, let's start git clone.