git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Hommey <mh@glandium.org>
To: Eric Raible <raible@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: RFC: perhaps a "new file" should not be deleted by "git reset --hard"
Date: Thu, 11 Sep 2008 08:14:54 +0200	[thread overview]
Message-ID: <20080911061454.GA8167@glandium.org> (raw)
In-Reply-To: <279b37b20809101212g57e9ad99qbf6fa15888679894@mail.gmail.com>

On Wed, Sep 10, 2008 at 12:12:21PM -0700, Eric Raible wrote:
> In http://marc.theaimsgroup.com/?l=git&m=114917892328066
> (references by http://git.or.cz/gitwiki/GitFaq), Linus says:
> 
> 'And "git reset" won't be deleting files it doesn't track (it had _better_
> not touch them), even more so when it has been told to ignore them, so it
> makes total sense to _not_ delete them when doing that reset.'
> 
> Now consider this example:
> 
> # Create a single commit in a new repo (so that we have a HEAD)
> mkdir xx
> cd xx
> git init
> git commit --allow-empty -m"initial"
> # Add an important file
> echo "Important stuff" > file42
> git add file42
> git status # -> new file:   file42
> ls # -> file42, or course
> git reset --hard
> ls # -> nothing
> 
> I would argue that as a "new file" (as reported by git status)
> that file42 was never actually tracked by git.  Sure, it _would_
> have been tracked in the future, but git never actually tracked it
> (it's not part of any commits).
> 
> So in this scenario wouldn't it make more sense for
> "git reset --hard" to handle file42 as "git reset" does
> instead of deleting it w/out a trace [1]?
> 
> The same question goes for "git checkout -f", too, I suppose.
> 
> I actually accidentally deleted hundred of newly added files yesterday
> doing just this.  https://mozy.com/?code=V3D4MM) saved my butt,
> but it wasn't pleasant.
> 
> - Eric
> 
> [1] - There's not even a reflog entry.  Sure, "git fsck" can be
> used, but that's hardly a friendly fallback.

Note that reflog only contains references to commit sha1s, so it can't
track index status. An index log could be interesting, though, but it
would need to expire much faster than reflog.

Mike

  parent reply	other threads:[~2008-09-11  6:16 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-10 19:12 RFC: perhaps a "new file" should not be deleted by "git reset --hard" Eric Raible
     [not found] ` <eafc0afe0809101912v72916d3hce9ae5d6812f0db8@mail.gmail.com>
2008-09-11  2:14   ` Changsheng Jiang
2008-09-11  2:38     ` Elijah Newren
2008-09-11 20:50       ` Eric Raible
2008-09-11 21:34         ` Junio C Hamano
2008-09-11 22:19           ` Eric Raible
2008-09-11 23:04             ` Jeff Whiteside
2008-09-11 23:29               ` Eric Raible
2008-09-11  2:46   ` Eric Raible
2008-09-11  6:05     ` Changsheng Jiang
2008-09-11  6:15       ` RFC: perhaps a Eric Raible
2008-09-11 16:32       ` RFC: perhaps a "new file" should not be deleted by "git reset --hard" Elijah Newren
     [not found]         ` <3ab397d0809111022m24c81bd9y2520f6be478babd3@mail.gmail.com>
2008-09-11 21:24           ` Eric Raible
2008-09-11 23:39             ` Miklos Vajna
2008-09-11 23:49               ` Eric Raible
2008-09-12 15:41                 ` Miklos Vajna
2008-09-11  6:14 ` Mike Hommey [this message]
2008-09-11 20:26   ` Eric Raible

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=20080911061454.GA8167@glandium.org \
    --to=mh@glandium.org \
    --cc=git@vger.kernel.org \
    --cc=raible@gmail.com \
    /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).