All of lore.kernel.org
 help / color / mirror / Atom feed
* Bug with .gitignore and branch switching
@ 2017-03-17 20:42 Nevada Sanchez
  2017-03-17 21:23 ` Junio C Hamano
  2017-03-17 21:54 ` Jonathan Nieder
  0 siblings, 2 replies; 8+ messages in thread
From: Nevada Sanchez @ 2017-03-17 20:42 UTC (permalink / raw)
  To: git

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
```

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-03-18  4:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-17 20:42 Bug with .gitignore and branch switching Nevada Sanchez
2017-03-17 21:23 ` Junio C Hamano
2017-03-17 21:58   ` Stefan Beller
2017-03-17 22:02   ` Jonathan Nieder
2017-03-17 22:36     ` Junio C Hamano
2017-03-18  3:40     ` Duy Nguyen
2017-03-18  4:30   ` Nevada Sanchez
2017-03-17 21:54 ` Jonathan Nieder

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.