# [RFC] git reset --recover

7 messages from 2008-03-03 to 2008-03-04. Participants: Ping Yin, Santi Béjar, Charles Bailey, Jay Soffian.
Thread: https://gitlist.dev/t/12458

## Ping Yin, 2008-03-03 14:59

Subject: [RFC] git reset --recover
Message-ID: <46dff0320803030659j2fa0325lf9c88b915ddb70da@mail.gmail.com>
URL: https://gitlist.dev/e/46dff0320803030659j2fa0325lf9c88b915ddb70da%40mail.gmail.com

```
Today i use git reset carelessly and lose all my changes!

To remind other people not do the same wrong thing, i share my
experience and propose a new option to avoid this happens again.
------------------------------------
foo
   .git
    bar
        file1
        file2
------------------------------------

In the direcotry structure above, i want to make bar as a repository
(which hasn't yet been tracked by foo repository). I should have done
this as follows

-------------------------------------------
cd bar
git init
git add
------------------------------------------

but i fogot to type "git init" which results that file1 and file2 are
added to index of foo repository. I tried to revert the operation
using "git reset". And the tragedy happened at that time because i
made so fatal  a mistake that i typed "git reset --hard". And i lost
all my files in bar dir!

So, can we introduce a --recover option for "git reset" to save the
foolish or careless people like me?

-- 
Ping Yin

```

## Santi Béjar, 2008-03-03 15:13

Subject: Re: [RFC] git reset --recover
Message-ID: <8aa486160803030713r7bdcf825sf994cbb20f096ccd@mail.gmail.com>
URL: https://gitlist.dev/e/8aa486160803030713r7bdcf825sf994cbb20f096ccd%40mail.gmail.com
In-Reply-To: <46dff0320803030659j2fa0325lf9c88b915ddb70da@mail.gmail.com>

```
On Mon, Mar 3, 2008 at 3:59 PM, Ping Yin <pkufranky@gmail.com> wrote:
> Today i use git reset carelessly and lose all my changes!
>
>  To remind other people not do the same wrong thing, i share my
>  experience and propose a new option to avoid this happens again.
>  ------------------------------------
>  foo
>    .git
>     bar
>         file1
>         file2
>  ------------------------------------
>
>  In the direcotry structure above, i want to make bar as a repository
>  (which hasn't yet been tracked by foo repository). I should have done
>  this as follows
>
>  -------------------------------------------
>  cd bar
>  git init
>  git add
>  ------------------------------------------
>
>  but i fogot to type "git init" which results that file1 and file2 are
>  added to index of foo repository. I tried to revert the operation
>  using "git reset". And the tragedy happened at that time because i
>  made so fatal  a mistake that i typed "git reset --hard". And i lost
>  all my files in bar dir!

"git reset" was sufficient.

>
>  So, can we introduce a --recover option for "git reset" to save the
>  foolish or careless people like me?

Another possibility would be to not delete a file that is absent in
both the old and new HEAD, even if it was in the index.

Santi

```

## Ping Yin, 2008-03-03 16:47

Subject: Re: [RFC] git reset --recover
Message-ID: <46dff0320803030847t42583badw1f5163d600a6fafb@mail.gmail.com>
URL: https://gitlist.dev/e/46dff0320803030847t42583badw1f5163d600a6fafb%40mail.gmail.com
In-Reply-To: <8aa486160803030713r7bdcf825sf994cbb20f096ccd@mail.gmail.com>

```
On Mon, Mar 3, 2008 at 11:13 PM, Santi Béjar <sbejar@gmail.com> wrote:
> On Mon, Mar 3, 2008 at 3:59 PM, Ping Yin <pkufranky@gmail.com> wrote:
>  > Today i use git reset carelessly and lose all my changes!
>  >

>  >
>  >  but i fogot to type "git init" which results that file1 and file2 are
>  >  added to index of foo repository. I tried to revert the operation
>  >  using "git reset". And the tragedy happened at that time because i
>  >  made so fatal  a mistake that i typed "git reset --hard". And i lost
>  >  all my files in bar dir!
>
>  "git reset" was sufficient.
>
I know about this, but i was just too careless.
>
>  >
>  >  So, can we introduce a --recover option for "git reset" to save the
>  >  foolish or careless people like me?
>
>  Another possibility would be to not delete a file that is absent in
>  both the old and new HEAD, even if it was in the index.
>
Sounds interesting.
>  Santi
>



-- 
Ping Yin

```

## Charles Bailey, 2008-03-03 17:02

Subject: Re: [RFC] git reset --recover
Message-ID: <20080303170242.GA30361@hashpling.org>
URL: https://gitlist.dev/e/20080303170242.GA30361%40hashpling.org
In-Reply-To: <46dff0320803030659j2fa0325lf9c88b915ddb70da@mail.gmail.com>

```
On Mon, Mar 03, 2008 at 10:59:14PM +0800, Ping Yin wrote:
> 
> but i fogot to type "git init" which results that file1 and file2 are
> added to index of foo repository. I tried to revert the operation
> using "git reset". And the tragedy happened at that time because i
> made so fatal  a mistake that i typed "git reset --hard". And i lost
> all my files in bar dir!

If they've been added to the index then the objects should be in your
git repository, it's just that it may be hard to find them.

Does 'git fsck' report some dangling blobs?  If so (some of) them
should be the content of your missing files.


```

## Ping Yin, 2008-03-04 05:21

Subject: Re: [RFC] git reset --recover
Message-ID: <46dff0320803032121v54612b40ke953348e86daf1f@mail.gmail.com>
URL: https://gitlist.dev/e/46dff0320803032121v54612b40ke953348e86daf1f%40mail.gmail.com
In-Reply-To: <20080303170242.GA30361@hashpling.org>

```
On Tue, Mar 4, 2008 at 1:02 AM, Charles Bailey <charles@hashpling.org> wrote:
> On Mon, Mar 03, 2008 at 10:59:14PM +0800, Ping Yin wrote:
>  >
>
>  If they've been added to the index then the objects should be in your
>  git repository, it's just that it may be hard to find them.
>
>  Does 'git fsck' report some dangling blobs?  If so (some of) them
>  should be the content of your missing files.
>
Good news. So can "--recover" help me find the lost blobs?


-- 
Ping Yin

```

## Jay Soffian, 2008-03-04 07:42

Subject: Re: [RFC] git reset --recover
Message-ID: <76718490803032342k18f05d4dte76aacd9292a1233@mail.gmail.com>
URL: https://gitlist.dev/e/76718490803032342k18f05d4dte76aacd9292a1233%40mail.gmail.com
In-Reply-To: <46dff0320803032121v54612b40ke953348e86daf1f@mail.gmail.com>

```
On Tue, Mar 4, 2008 at 12:21 AM, Ping Yin <pkufranky@gmail.com> wrote:
> On Tue, Mar 4, 2008 at 1:02 AM, Charles Bailey <charles@hashpling.org> wrote:
>  >
>  >  Does 'git fsck' report some dangling blobs?  If so (some of) them
>  >  should be the content of your missing files.
>  >
>  Good news. So can "--recover" help me find the lost blobs?

git fsck --lost-found. Look under .git/lost-found/other for your blobs.
Anything that's not 41 bytes is a file.

j.

```

## Ping Yin, 2008-03-04 08:22

Subject: Re: [RFC] git reset --recover
Message-ID: <46dff0320803040022r6babc3d2n745bc8a08b8bf197@mail.gmail.com>
URL: https://gitlist.dev/e/46dff0320803040022r6babc3d2n745bc8a08b8bf197%40mail.gmail.com
In-Reply-To: <76718490803032342k18f05d4dte76aacd9292a1233@mail.gmail.com>

```
On Tue, Mar 4, 2008 at 3:42 PM, Jay Soffian <jaysoffian@gmail.com> wrote:
> On Tue, Mar 4, 2008 at 12:21 AM, Ping Yin <pkufranky@gmail.com> wrote:
>  > On Tue, Mar 4, 2008 at 1:02 AM, Charles Bailey <charles@hashpling.org> wrote:
>  >  >
>
> >  >  Does 'git fsck' report some dangling blobs?  If so (some of) them
>  >  >  should be the content of your missing files.
>  >  >
>  >  Good news. So can "--recover" help me find the lost blobs?
>
>  git fsck --lost-found. Look under .git/lost-found/other for your blobs.
>  Anything that's not 41 bytes is a file.
>
Thanks for pointing me that.
>  j.
>



-- 
Ping Yin

```
