Despite having a global gitignore on Windows OS, I am still getting a bunch of "Untracked files".
Below is a truncated list of what it looks like:
Untracked files:
(use "git add <file>..." to include in what will be committed)
foo/bar/__pycache__/
foo/pkg_name.egg-info/
scripts/MainProcess.log
scripts/__pycache__/
test/foo/bar/__pycache__/
test/test_pkg_name.egg-info/
venv/
What am I doing wrong? What am I missing?
Background
On Windows 10 Pro my git
version is git version 2.34.1.windows.1
, and here's my ~/.gitconfig
:
[core]
excludesfile = C:\\Users\\username\\.config\\git\\ignore
git config --list --show-origin
outputs:
file:C:/Users/username/.gitconfig core.excludesfile=C:\Users\username\.config\git\ignore
git check-ignore **.*
outputs nothing.
Here is the PowerShell script used to generate the global gitignore:
New-Item -ItemType Directory -Force -Path $Env:USERPROFILE\.config\git
'Global/JetBrains','Global/Vim','Global/VisualStudioCode','Global/macOS','Python','Terraform' `
| ForEach-Object {
Invoke-RestMethod -Uri "https://raw.githubusercontent.com/github/gitignore/master/$PSItem.gitignore"
} > $Env:USERPROFILE\.config\git\ignore
git config --global core.excludesfile $Env:USERPROFILE\.config\git\ignore
The result is a C:\Users\username\.config\git\ignore
file in UTF-16 LE encoding with LF
endings. You can see the full file in a Pastebin here: https://pastebin.com/a730JHtc
Lastly, the checked out repo also has a per-repo .gitignore
(UTF-8 encoding, CRLF
line endings) inside that looks like this:
# Follow README.rst instructions on global gitignore
The README.rst
instructions it speaks of have been translated into this question.
Research
There are many similar questions like this, none of them solved my problem:
- Global Git ignore
- My gitignore_global is not working even though gitconfig specify the absolute path
- global gitignore being, um, ignored
- https://mike.place/2020/global-gitignore/
- https://infyom.com/blog/how-to-setup-global-git-ignore-in-window
Similar unanswered questions: