threads / rfc / 12458

[RFC] git reset --recover

Subject: [RFC] git reset --recover

## tl;dr

7 messages between Mar 3, 2008 and Mar 4, 2008.

replies: 6people: 4as markdown or json

Ping Yin· Mar 3, 2008, 14:59 UTC · lore
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· Mar 3, 2008, 15:13 UTC · re: Ping Yin · lore

Re: [RFC] git reset --recover

On Mon, Mar 3, 2008 at 3:59 PM, Ping Yin <pkufranky@gmail.com> wrote:
Show 27 quoted lines
> 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· Mar 3, 2008, 16:47 UTC · re: Santi Béjar · lore

Re: [RFC] git reset --recover

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!
>  >
Show 9 quoted lines
>  >
>  >  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.
Show 8 quoted lines
>
>  >
>  >  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· Mar 3, 2008, 17:02 UTC · re: Ping Yin · lore

Re: [RFC] git reset --recover

On Mon, Mar 03, 2008 at 10:59:14PM +0800, Ping Yin wrote:
Show 6 quoted lines
> 
> 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· Mar 4, 2008, 05:21 UTC · re: Charles Bailey · lore

Re: [RFC] git reset --recover

On Tue, Mar 4, 2008 at 1:02 AM, Charles Bailey <charles@hashpling.org> wrote:
Show 9 quoted lines
> 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· Mar 4, 2008, 07:42 UTC · re: Ping Yin · lore

Re: [RFC] git reset --recover

On Tue, Mar 4, 2008 at 12:21 AM, Ping Yin <pkufranky@gmail.com> wrote:
Show 6 quoted lines
> 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· Mar 4, 2008, 08:22 UTC · re: Jay Soffian · lore

Re: [RFC] git reset --recover

On Tue, Mar 4, 2008 at 3:42 PM, Jay Soffian <jaysoffian@gmail.com> wrote:
Show 12 quoted lines
> 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

← back to recent threads