git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RFC: perhaps a "new file" should not be deleted by "git reset --hard"
@ 2008-09-10 19:12 Eric Raible
       [not found] ` <eafc0afe0809101912v72916d3hce9ae5d6812f0db8@mail.gmail.com>
  2008-09-11  6:14 ` Mike Hommey
  0 siblings, 2 replies; 18+ messages in thread
From: Eric Raible @ 2008-09-10 19:12 UTC (permalink / raw)
  To: Git Mailing List

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.

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

end of thread, other threads:[~2008-09-12 15:42 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2008-09-11 20:26   ` Eric Raible

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).