From: Jeff King <peff@peff.net>
To: Johannes Sixt <j6t@kdbg.org>
Cc: Manuel Guilamo <manuel.guilamo@publicis.com.do>, git@vger.kernel.org
Subject: Re: Prevent reset --hard from deleting everything if one doesn't have any commits yet
Date: Fri, 1 Mar 2019 08:47:59 -0500 [thread overview]
Message-ID: <20190301134759.GA13402@sigill.intra.peff.net> (raw)
In-Reply-To: <d1b34077-1c0e-7a2a-d2c7-da013dd56cd9@kdbg.org>
On Fri, Mar 01, 2019 at 07:56:00AM +0100, Johannes Sixt wrote:
> Am 28.02.19 um 22:43 schrieb Manuel Guilamo:
> > I accidentally executed git reset —hard in a project that doesn’t
> > have any commits yet. git erased everything, everything I’ve worked
> > the past week, I believe this is not a desired behavior, considering
> > I’m not able to undo that action, because git doesn’t have any
> > history whatsoever.
>
> I tested this, and it does not happen for me as long as I do not `git
> add` anything.
>
> So, I assume you did `git add` your content and then you did a `git
> reset --hard`. In that case, I'm afraid Git behaved as designed and
> "doesn't have any commits" is a red herring.
Wouldn't that mean all of the file data is available in the object
database? Unfortunately without an index, there's nothing to mark which
file was which. But `git fsck --lost-found` should copy out all of the
file content into .git/lost-found.
-Peff
next prev parent reply other threads:[~2019-03-01 13:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-28 21:43 Prevent reset --hard from deleting everything if one doesn't have any commits yet Manuel Guilamo
2019-03-01 6:56 ` Johannes Sixt
2019-03-01 13:46 ` Manuel Guilamo
2019-03-01 13:47 ` Jeff King [this message]
2019-03-03 1:38 ` Junio C Hamano
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=20190301134759.GA13402@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=j6t@kdbg.org \
--cc=manuel.guilamo@publicis.com.do \
/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).