Ir para o conteúdo
ou

Software livre Brasil

Jonh Wendell

Twitter

redirection forbidden: http://api.twitter.com/1/statuses/user_timeline.rss?screen_name=jwendell -> https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=jwendell

 Voltar a Blog
Tela cheia

Recovering lost files after a git reset –hard

2 de Outubro de 2014, 10:31 , por Software Livre Brasil - 0sem comentários ainda | Ninguém está seguindo este artigo ainda.
Visualizado 5 vezes

This morning I’ve messed things up in my env…

I did a commit yesterday and thought I had pushed it, but not.
Today I did a git pull and was asked to do a merge, because there were changes in the remote.

I totally ignored this (don’t ask me why, perhaps absence of coffee…) and did a git reset –hard HEAD^^

So, yep, I lost my commit that existed only in my machine (this commit in particular was a file addition).

After blaming myself a lot, and a bit of google search, I’ve found this amazing blog post: http://zsoltfabok.com/blog/2012/06/recover-deleted-files-with-git/

I’m summarizing here the steps to have your commit (in my case, the file) back:

git fsck --no-reflog

This command will return a hash for the lost commit, something like

dangling commit fafeade9f348b18f37835ab49dab40172efde693

You can use this hash to do a checkout, for instance, and recover your file. \o/

So, let’s have a bit of coffee now :)


Fonte: http://www.bani.com.br/2014/10/recovering-lost-files-after-a-git-reset-hard/

0sem comentários ainda

Enviar um comentário

Os campos são obrigatórios.

Se você é um usuário registrado, pode se identificar e ser reconhecido automaticamente.