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

"git checkout" obliterates not-yet-ignored files

From
Matthias Urlichs <matthias@urlichs.de>
Date
Nov 4, 2018, 19:29 UTC
Message-ID
<949b99d6-c681-49ed-4a4e-d33e0f6487d3@urlichs.de>
Hi,

the problem: suppose I decide that a local file should no longer be controlled by git. Thus I add it to .gitignore and then "git rm --cached" it. So far so good.

However, if I subsequently modify that file and then go back to a commit that still contains it, my local changes will be obliterated.

IMHO that's a bug – .gitignore should only be used for (not) adding non-version-controlled files. It does not tell git to ignore changes (in files that *are* under version control), and thus it should not allow any git command to simply overwrite a file.

-- 
-- Matthias Urlichs
Message 1 of 1 in “"git checkout" obliterates not-yet-ignored files”
  1. Matthias UrlichsNov 4, 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.