Radivarig Radivarig - 1 year ago 117
Git Question

Why does "git add *" excludes .gitignore?

I've got .gitignore file with names of excluded files. When I delete .git folder and do

git init
, after
git add *
I would expect all files to be added that are not ignored by .gitignore. However, .gitignore shows as untracked file in
git status
and I have to manually add it with
git add .gitignore
even if I include
in .gitignore.

qzb qzb
Answer Source

Because * in your command is actually replaced with names of files (and directories) from your current directory except ones staring w .. If you want to include also .gitignore you should call:

git add * .gitignore

If you want include all dot files call:

git add * .[!.]*

If you are using zsh, you can use simpler pattern:

 git add * .*
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download