Generally speaking don't use git add .
as an everyday command. Especially if it's not what you want. And if you are adding a massive load of files, just follow it with a git reset <file to not be added>
before your commit.
The only files git won't add
when are the .git
folder becuase it knows that is its meta data, and anything not already committed that is listed in a committed .gitignore
file.
There is no such thing to git
as a "hidden file". Technically there is no such thing in Windows, OSX or Linux, there are files that are not normally displayed in UI windows, or by ls
on the command line, but they are not "hidden" they just match a name pattern that says to not normally display. git
doesn't care about any of that and it shouldn't.
And no I don't remember what happens if you have already committed a file and then make it git ignored.
In general I don't use git add .
I'm using git add -u
for all tracked files with changes to be picked up and then using git reset
on the ones I didn't want added, or git add -p (optionally with a file name)
for interactive patch adding, or git add prefix*
to get a group of files. I only ever generally use git add .
for a first commit and then I will trim things out of that with git reset
before committing. I'm also usually checking status before I even add or commit.
Blindly using git add .
is a great way to inadvertantly commit test files, password files, diffs, and all sorts of other things that you don't want into the repository.