I recently moved from Windows to Kubuntu, and while I was using git to create a new project, I stumbled on something weird: git doesn't seem to ignore folders starting with a period by default. If I remember correcty, Windows version of git did that, and I think I read it on SO but I cannot find a source to back up my words.
Here's output of git status
. My gitignore file is empty.
...
Untracked files:
(use "git add <file>..." to include in what will be commited)
.build/
.dist/
...
Am I imagining stuff and this is the correct behaviour? Or is this something that's not supposed to happen?
I recently moved from Windows to Kubuntu, and while I was using git to create a new project, I stumbled on something weird: git doesn't seem to ignore folders starting with a period by default. If I remember correcty, Windows version of git did that, and I think I read it on SO but I cannot find a source to back up my words.
Here's output of git status
. My gitignore file is empty.
...
Untracked files:
(use "git add <file>..." to include in what will be commited)
.build/
.dist/
...
Am I imagining stuff and this is the correct behaviour? Or is this something that's not supposed to happen?
Share Improve this question edited Feb 1 at 16:16 Ulrich Eckhardt 17.4k5 gold badges31 silver badges58 bronze badges asked Feb 1 at 15:31 postcoital.solitairepostcoital.solitaire 3121 gold badge2 silver badges13 bronze badges 11 | Show 6 more comments1 Answer
Reset to default 2"Am I imagining stuff and this is the correct behaviour?"
Yes, it is, both on Windows and Linux. Thanks to phd's comment I remembered why I thought it should ignore such folders: I created a virtual environment with python -m venv .v
and git ignored it, so I thought that it ignored it because the name started with a period. I didn't take into account that venv itself created a gitignore file with a *
which ignored the whole directory, hence it wasn't showing on git status
. So yes, I am imagining stuff.
UPD: Seems that python -m venv .v
sometimes creates a gitignore file. It does on Windows as of now, but not on Kubuntu.
git/windows
ignores folders starting with a period by default. Try to put.*/
in .gitignore – Philippe Commented Feb 1 at 16:25cd C:\TMP
,git init
,md .test-dir
,echo test >.test-dir\test-file
,git status
— it shows.test-dir
as untracked. Perhaps you've tried with empty directories — but Git always ignores empty dirs because it only tracks file content. – phd Commented Feb 1 at 16:28git status
." This directory is ignored regardless of the leading dot. The directory will be ignored until you create a file in it. Then it will be visible ingit status
as untracked. Even in Windows. – phd Commented Feb 1 at 16:35