* Prevent reset --hard from deleting everything if one doesn't have any commits yet
@ 2019-02-28 21:43 Manuel Guilamo
2019-03-01 6:56 ` Johannes Sixt
0 siblings, 1 reply; 5+ messages in thread
From: Manuel Guilamo @ 2019-02-28 21:43 UTC (permalink / raw)
To: git
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Prevent reset --hard from deleting everything if one doesn't have any commits yet
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
0 siblings, 2 replies; 5+ messages in thread
From: Johannes Sixt @ 2019-03-01 6:56 UTC (permalink / raw)
To: Manuel Guilamo; +Cc: git
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Prevent reset --hard from deleting everything if one doesn't have any commits yet
2019-03-01 6:56 ` Johannes Sixt
@ 2019-03-01 13:46 ` Manuel Guilamo
2019-03-01 13:47 ` Jeff King
1 sibling, 0 replies; 5+ messages in thread
From: Manuel Guilamo @ 2019-03-01 13:46 UTC (permalink / raw)
To: Johannes Sixt; +Cc: git
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.
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Prevent reset --hard from deleting everything if one doesn't have any commits yet
2019-03-01 6:56 ` Johannes Sixt
2019-03-01 13:46 ` Manuel Guilamo
@ 2019-03-01 13:47 ` Jeff King
2019-03-03 1:38 ` Junio C Hamano
1 sibling, 1 reply; 5+ messages in thread
From: Jeff King @ 2019-03-01 13:47 UTC (permalink / raw)
To: Johannes Sixt; +Cc: Manuel Guilamo, git
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Prevent reset --hard from deleting everything if one doesn't have any commits yet
2019-03-01 13:47 ` Jeff King
@ 2019-03-03 1:38 ` Junio C Hamano
0 siblings, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2019-03-03 1:38 UTC (permalink / raw)
To: Jeff King; +Cc: Johannes Sixt, Manuel Guilamo, git
Jeff King <peff@peff.net> writes:
> 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.
If we had a hierachically stored index that stores subdirectory
contents as a tree (or some tree-like things), "fsck --lost-found"
would have been able to recover even pathnames, but with the current
flat index in a fresh directory without any commit, we'd get bunch
of blobs without any clue as to where each of them goes. It would
be far better than nothing, but leaves room for improvement.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-03-03 1:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2019-03-03 1:38 ` Junio C Hamano
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).