'Git warning "encountered old-style '/home/user/.gitignore' that should be '%(prefix)/home/user/.gitignore'"

Using git version 2.35.1.windows.2, all Git invocations include this warning at least once:

PS C:\Users\BoppreH\Desktop\source\keyboard> git status
warning: encountered old-style '/home/boppreh/.gitignore' that should be '%(prefix)/home/boppreh/.gitignore'
On branch new_core
Your branch is up to date with 'origin/new_core'.
[...]

Sometimes multiple times:

PS C:\Users\BoppreH\Desktop\source\keyboard> git pull
warning: encountered old-style '/home/boppreh/.gitignore' that should be '%(prefix)/home/boppreh/.gitignore'
warning: encountered old-style '/home/boppreh/.gitignore' that should be '%(prefix)/home/boppreh/.gitignore'
warning: encountered old-style '/home/boppreh/.gitignore' that should be '%(prefix)/home/boppreh/.gitignore'
warning: encountered old-style '/home/boppreh/.gitignore' that should be '%(prefix)/home/boppreh/.gitignore'
warning: encountered old-style '/home/boppreh/.gitignore' that should be '%(prefix)/home/boppreh/.gitignore'
Already up to date.

Which is confusing, because I'm on Windows and there's no .gitignore file in my home folder.

What is causing this warning?

git


Solution 1:[1]

The user configuration file at ~/.gitconfig contained the following entry:

[core]
    excludesfile = /home/boppreh/.gitignore

So the problem is that I assumed the leading slash made the path absolute (it doesn't), and I transferred a .gitconfig file from a Linux machine without the matching .gitignore file.

My solution was to remove the offending line.

Solution 2:[2]

For the latest git releases for Windows, prepending %(prefix) on any root file-reference is suggested.

Otherwise you will get the warning that you are referring to. The amount of times that you will get it depends on the git command that you are running. Which effectively reflects the number of times that such references in your .gitconfig file are parsed.

I believe if you update the offending line as below, you will not get the warning message.

[core]
   excludesfile = %(prefix)/home/boppreh/.gitignore

BTW with Git for Windows v2.35.3 there was a bug-fix released that was related to %(prefix) when using Windows Subsystem for Linux (WSL).

Might be related with your case if you add the prefix and you are still getting the warning.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 BoppreH
Solution 2 idrositis