git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git overwriting local ignored files?

From
David Mandelberg <david@mandelberg.org>
Date
Nov 24, 2018, 14:37 UTC
Message-ID
<7ac49733-2e62-7d29-36aa-99df4124b54c@mandelberg.org>
In-Reply-To
<xmqqftvr2jfo.fsf@gitster-ct.c.googlers.com>
On 11/23/18 11:22 PM, Junio C Hamano wrote:
Show 11 quoted lines
> David Mandelberg <david@mandelberg.org> writes:
> 
>> It seems that git is overwriting my local files on merge if they're in
>> .gitignore. See command transcript below. I searched `git help config`
>> and Google, but I couldn't find any way to prevent it. Am I missing
>> something? (The reason I care about ignored files is that I'm using
>> git with a working directory of $HOME to manage my dotfiles, and most
>> files in my $HOME are not tracked by git but are still important.)
> 
> The .gitignore file is to list "ignored and expendable" class of
> files; there is no "ignored but precious class" in Git.

Ok. Would a patch be welcome? I have three ideas for how to implement it, and I'm not sure which is better.

1. Add a boolean config option called core.preserveIgnore (or similar). 
I'm guessing this is the least amount of work, but it's not very 
flexible. I'm also not sure how it should work with `git clean`.
2. Add some syntax to the .gitignore format so the same file can list 
both "ignored and expendable" and "ignored and precious". I could see 
using this to mark compiled files as ignored+expendable and per-repo 
editor/IDE config files as ignored+precious. Do you have any idea how 
big of a patch this would be? Or any idea for the new syntax? I think 
starting a line with "\x" where x is any character not currently escaped 
by a backslash would cause the least disruption to existing .gitignore 
files.
3. Like (2), but use a separate file instead of .gitignore (and the 
other git-ignore files).
Any thoughts?
-- 
https://david.mandelberg.org/
Previous: Junio C HamanoNext: Konstantin Khomoutov
Message 3 of 6 in “git overwriting local ignored files?”
  1. David MandelbergNov 24, 2018
  2. Junio C HamanoNov 24, 2018
  3. David MandelbergNov 24, 2018
  4. Konstantin KhomoutovNov 24, 2018
  5. Konstantin KhomoutovNov 24, 2018
  6. David MandelbergNov 25, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.