Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

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?

like image 594
BoppreH Avatar asked Sep 08 '25 13:09

BoppreH


2 Answers

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.

like image 185
idrositis Avatar answered Sep 11 '25 07:09

idrositis


A simple ~ in the file name solved this for me, with the added benefit that it works on Windows and Unix.

[core]
  excludesfile = ~/.gitignore

The warning should be gone.

like image 40
marcelocra Avatar answered Sep 11 '25 07:09

marcelocra