Search code examples
windowsgitgitignorecase-sensitivegit-config

Git Ignore Case-Sensitive Folder Names


There's lots of questions/answers on committing filename changes on case-insensitive OS's, but my problem is git-ignoring a case sensitive folder (on both linux and windows).

Example: key 3rd-party software tool generates folder Test/ with build artifacts for testing. Standard location for test files in our system are test/ folders. The gitignore has **/Test/ (what we don't want to see/commit), but then test/ folders don't show up (what we do want to see/commit).

Testing this on latest windows git-bash, setting/toggling core.ignorecase = false doesn't seem to change the behavior.

Edit: From VonC's useful command to check per-file gitignore status, a demo

git init
mkdir -p d1/Test d2/test
touch d1/Test/hidden d2/test/visible
git config -f .gitconfig --add core.ignorecase false
echo "**/Test/" > .gitignore

git status

Untracked files:
.gitconfig
.gitignore
# Missing d2/test/visible

git -c core.ignorecase=false check-ignore -v -- d1/Test/hidden

.gitignore:1:**/Test/    d1/Test/hidden

git -c core.ignorecase=false check-ignore -v -- d2/test/visible

# Nothing, which is correct

Second Edit:

Which leads to the (less) obvious problem: forgetting to add .gitconfig to local config: (of course it won't behave like it's changed if it's not actually changed...)

git config --local include.path ../.gitconfig


Solution

  • setting/toggling core.ignorecase = false doesn't seem to change the behavior.

    It should though.

    Test it out with a file within that folder:

    git -c core.ignorecase=false check-ignore -v  --  Test/a/File
    

    Another approach would be to sidestep the issue entirely and make sure:

    • the standard location is, for instance, in tests/ instead of test/,
    • or the key software generates tests in Tests/ instead of Test/.