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

Bug with .gitignore and branch switching

From
NSNevada Sanchez <sanchez.nevada@gmail.com>
Date
Mar 17, 2017, 20:42 UTC
Message-ID
<CAPUVn2u0Uos2mT5+4ejj8m0okNK6XwerL6ce2miHfhtuEs-ZnQ@mail.gmail.com>

Here's an easy to reproduce bug. It's the only example I know of where git legitimately loses data in a way that is unrecoverable, unexpected, and without warning.

``` git --version # git version 2.12.0

mkdir git-demo cd git-demo

git init

# Commit a file that will end up in .gitignore echo 'original settings' > mine.conf git add mine.conf git commit -m "Unknowingly committed my settings."

echo '*.conf' > .gitignore git add .gitignore git commit -m "Users shouldn't commit their settings"

# Spin off a feature branch here (but don't check it out) git branch feature

# Realize that we don't want that file committed git rm mine.conf git commit -m "Delete mine.conf"

echo 'Lots of laboriously tuned settings' > mine.conf

# Hop on the feature branch to do some work git checkout feature

# Hmmm... My settings are gone cat mine.conf # original settings

# Lemme hop back git checkout master

# Wait... they are gone for good! cat mine.conf # cat: mine.conf: No such file or directory ```

Next: Junio C Hamano
Message 1 of 8 in “Bug with .gitignore and branch switching”
  1. Nevada SanchezMar 17, 2017
  2. Junio C HamanoMar 17, 2017
  3. Jonathan NiederMar 17, 2017
  4. Junio C HamanoMar 17, 2017
  5. Duy NguyenMar 18, 2017
  6. Stefan BellerMar 17, 2017
  7. Nevada SanchezMar 18, 2017
  8. Jonathan NiederMar 17, 2017

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.