git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniele Segato <daniele.bilug@gmail.com>
To: Git Mailing List <git@vger.kernel.org>
Subject: ignored file can be deleted silently
Date: Thu, 5 May 2011 10:40:08 +0200	[thread overview]
Message-ID: <BANLkTinEupQKfBofhH-qKD6gLGWyWRbGvw@mail.gmail.com> (raw)

Hi,

I noticed that when i put a file in the git ignore If i switch to a
branch where the file is present and versioned git delete my local
ignored file replacing it with the content of the branch I switched
this is done silently and the file is gone forever if I don't have a
copy somewhere

this is a stupid testcase:

$ git init
$ echo 'content I dont care about' > testcase.txt
$ git add testcase.txt
$ git commit -m "content I don't care about"
$ git checkout -b test
$ echo 'testcase.txt' > .gitignore
$ git rm testcase.txt
$ echo 'content I do care a lot' > testcase.txt
$ git add .gitignore
$ git commit -m "ignored testcase.txt"
$ cat testcase.txt
content I do care a lot
$ git checkout master
$ cat testcase.txt
$ git checkout test
$ ls testcase.txt
ls: testcase.txt: No such file or directory


This may sound stupid (put a content you care about in an ignored
file) but think about environment configuration files

it is common to initially commit them (wrong) then copy them to a
template file adding the original to ignore
especially if you are migrating from subversion where it is really
common practice to have local modified file you never commit (and I
think git really miss a *feature* like this)
they can be very big and with a lot of environment options...

if for some reason I had to switch to an old commit where the file is
still not ignored to do some test and I forgot that commit do not
ignore my little environment file I can lose it...

I think git should warn me in some way and, at least, give me a backup
of the file

what do you think about it?

regards,
Daniele Segato

             reply	other threads:[~2011-05-05  8:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-05  8:40 Daniele Segato [this message]
2011-05-05 14:18 ` ignored file can be deleted silently Nguyen Thai Ngoc Duy
2011-05-05 16:49   ` Junio C Hamano
2011-05-05 19:51     ` Daniele Segato

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BANLkTinEupQKfBofhH-qKD6gLGWyWRbGvw@mail.gmail.com \
    --to=daniele.bilug@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).