-1

I got stuck cause I forgot to put a message to a commit. So, since i did not how to exit the vim (or whatever) I just got into the .git folder and deleted every file in there.

The thing is that now I get this message:

fatal: bad object HEAD

and if I use the git fsck this:

error: refs/heads/master: invalid sha1 pointer 92921ef183ebb792a66213ecfd31fa0a4dc32685
error: refs/original/refs/heads/master: invalid sha1 pointer 58c2fbc2fa2645100f45c919cbda6b5bea3f44c3
error: refs/remotes/origin/master: invalid sha1 pointer 92921ef183ebb792a66213ecfd31fa0a4dc32685
error: HEAD: invalid sha1 pointer 92921ef183ebb792a66213ecfd31fa0a4dc32685
error: HEAD: invalid reflog entry 92921ef183ebb792a66213ecfd31fa0a4dc32685
notice: No default references

Finally, I've tried this and got this:

Move-Item : No se encuentra ningún parámetro que coincida con el nombre del parámetro 'rf'.
+ mv -rf .git
+    ~~~
    + CategoryInfo          : InvalidArgument: (:) [Move-Item], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.MoveItemCommand

No se encuentra ningún parámetro que coincida con el nombre del parámetro

means something like:

Can't find any parameter that matches with the name of the parameter 'rf'

and same happens with 'mv'.

PD:I know that I shouldn't have deleted everything just like that. But now I don't know how to keep working.

  • "I know that I shouldn't have deleted everything just like that" Indeed. You destroyed your repo and now you wonder why things are not working? Basically at this point all is lost. Delete the _.git_ folder entirely; it is worse than useless. – matt Jan 26 '22 at 04:18
  • I really don't care about the repo, I got the files I need in a folder in my pc. And I can't delete the .git folder, there is another folder inside that cannot be deleted. And I am not wondering why things are not working. I now why that is. I am wondering how to make them work again. – Juan Ignacio Melo Jan 26 '22 at 04:21
  • What does "work again" mean? Without the repo there is nothing for Git to do. And you destroyed the repo. So there is nothing to "work". – matt Jan 26 '22 at 04:34

1 Answers1

0

Deleted files inside the .git folder?! Really???

I suggest you do a fresh git clone because I don't think that's going to be fixed magically with whatever command you try.

To exit vim (the best editor ever), you use:

ZZ

or

:wq

when you want to write and exit, or:

:q!

When you want to exit without saving. In this case, git does nothing.

Another solution, in case you end up in another weird editor...

mv .git safe-git

Kill that editor in some way... and then

mv safe-git .git

Because if the .git folder disappear, nothing is going to happen... (I would be surprised that git commit or such keep files open while you are editing; but even if that's the case, blowing your editor away by killing the process should have the same effect as quitting the editor without adding a message and thus aborting the commit).

Alexis Wilke
  • 19,179
  • 10
  • 84
  • 156
  • Thank you, I found that information. The thing is that i closed the console with the ```vim``` thing. So I could not do another action cause that vim thing was "still running". – Juan Ignacio Melo Jan 26 '22 at 04:24
  • @JuanIgnacioMelo Ah. That could be a lock issue... I think that git creates a lock when you do a commit so two people (including yourself in another console) can't attempt that command simultaneously. – Alexis Wilke Jan 26 '22 at 05:59