Skip to contentSkip to conversation

No error when overwriting ignored files

DISCUSSION Horst von Brand 4 participants 4 messages Apr 7, 2021

lore
Share & tools
lore
#0 lore raw

When pulling from a repository that tracks a file listed in .gitignore that would overwrite a local file, this is not reported.

For example, in the attached repositories, when doing git pull tst1 in tst2, it is (correctly) reported that ignored.not would be overwritten, while ignored.txt is not reported.

Signature · 4 lines
Dr. Horst H. von Brand                   User #22616 counter.li.org
Departamento de Informatica                    Fono: +56 32 2654431
Universidad Tecnica Federico Santa Maria             +56 32 2654239
Casilla 110-V, Valparaiso, Chile 2340000       Fax:  +56 32 2797513
#1 lore raw
Quoted 6 lines · Horst von Brand

When pulling from a repository that tracks a file listed in .gitignore that would overwrite a local file, this is not reported.

For example, in the attached repositories, when doing git pull tst1 in tst2, it is (correctly) reported that ignored.not would be overwritten, while ignored.txt is not reported.

This is behaving as intended. Ignored files are not considered "precious". You can find more discussion by searching for that term in the list archive.

There is no concept of "ignored but precious" in Git. However, here's an old patch series that tries to move in that direction (using an attribute):

https://lore.kernel.org/git/[email protected]/

AFAIK nobody is actively working on it right now.

-Peff

#3 lore raw
In reply to Horst von Brand
Quoted 3 lines · Horst von Brand

When pulling from a repository that tracks a file listed in .gitignore that would overwrite a local file, this is not reported.

Git has the notion of "not to be tracked (i.e. added to the index or committed) and expendable files", and they are called "ignored" files. And ".gitignore" and .git/info/exclude mechanism is used to mark these paths.

There is no notion of "not to be tracked but precious files" or mechanism to mark paths as such. So the behaviour you observed is fully expected and working as designed.

Thanks.

#2 lore raw
In reply to Jeff King
Quoted 13 lines · Jeff King
Quoted 6 lines · Horst von Brand

When pulling from a repository that tracks a file listed in .gitignore that would overwrite a local file, this is not reported.

For example, in the attached repositories, when doing git pull tst1 in tst2, it is (correctly) reported that ignored.not would be overwritten, while ignored.txt is not reported.

This is behaving as intended. Ignored files are not considered "precious". You can find more discussion by searching for that term in the list archive.

Quoted 7 lines

There is no concept of "ignored but precious" in Git. However, here's an old patch series that tries to move in that direction (using an attribute):

https://lore.kernel.org/git/[email protected]/

AFAIK nobody is actively working on it right now.

Having re-read that thread now I still think by far the most useful way forward with this for anyone who's interested is to investigate/add missing tests for our current behavior, why/when it got introduced, whether anyone wanted it or if it was emergent etc. See [1] for a summary.

That's quite a bit of work, but is work that someone with little/no previous familiarity with git's development should be able to do with enough time & motivation....

1. https://lore.kernel.org/git/[email protected]/