git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Prevent reset --hard from deleting everything if one doesn't have any commits yet

From
MGManuel Guilamo <manuel.guilamo@publicis.com.do>
Date
Mar 1, 2019, 13:46 UTC
Message-ID
<11C5FB4E-A4FF-430A-9305-E5BDA6A11049@publicis.com.do>
In-Reply-To
<d1b34077-1c0e-7a2a-d2c7-da013dd56cd9@kdbg.org>
Oh yes... I did. Sigh
Regardless,
wouldn’t be nice to have a confirmation in cases like this? considering git isn’t only used by experts. It would’ve helped me A LOT, that’s for sure… and I’m 100% sure I won’t be that last person in the history of git that would suffer this.
Thank you for your quick reply.
Show 17 quoted lines
> On Mar 1, 2019, at 2:56 AM, Johannes Sixt <j6t@kdbg.org> 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.
> 
> -- Hannes
Previous: Johannes SixtNext: Jeff King
Message 3 of 5 in “Prevent reset --hard from deleting everything if one doesn't have any commits yet”
  1. Manuel GuilamoFeb 28, 2019
  2. Johannes SixtMar 1, 2019
  3. Manuel GuilamoMar 1, 2019
  4. Jeff KingMar 1, 2019
  5. Junio C HamanoMar 3, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.