Recover git repository Feature

Asked

Viewed 305 times

0

Create a Feature for my new project, do some commits and then push to the cloud. I deleted my local Feature and ended up deleting Feature from the cloud as well.

I wonder if you have how to recover a deleted cloud Feature in my git? if yes, what procedure should be done?

NOTE: I am using Soucetreen to manage the versions of my files.

  • Possible duplicate. <br> https://answall.com/questions/204286/como-recuperar-umbra%C3%A7o-deleted-no-git =D

1 answer

0


Imagine a scenario where you’ve used a rebase on your branch and lost it in n commits or reset it --hard.

Now all commits have been lost or rebased, simply placed, they are no longer recognizable using their previous commit Ids.

If you’d like to revert to the state of the Repo before rebasing or resetting --hard, you can use git reflog.

Git internally maintains a status log of your HEAD and all changes that have been made to it.

 git reflog

7b4ab0e HEAD@{0}: checkout: moving from 3-dummy to master
a256440 HEAD@{1}: commit (amend): Fixes Dummy Issue
d848c34 HEAD@{2}: commit: Fixes issue#3   
09dca41 HEAD@{3}: commit: Issue 3 first cut
7b4ab0e HEAD@{4}: checkout: moving from master to 3-dummy
7b4ab0e HEAD@{5}: clone: from [email protected]:abishekk92/box.git

If you notice, all changes in HEAD state are recorded. When we know what state we want to move HEAD to,

git reset --hard HEAD@{x}

If you have changes and can’t perform a forced reboot for a particular reflog, but still want the commit changes lost.

git cherry-pick <commit-hash>

Note: And also git cleans your blob as soon as it reaches 5,000 objects, so it wouldn’t be possible to reset to a very old state, unless you’ve set up git to do it.

  • Please detail your answer better.

  • the git reflog command makes it possible for you to recover "anything" that was deleted, even if it was deleted permanently, from a read in the documentation that explains everything correctly how it works

  • 1

    No, it was not to be more detailed for me, and in the comments, but in your answer! ;-) The goal of Stackoverflow is to serve as a repository of knowledge for developers, through questions and answers, so if anyone ever has this question, your answer may be useful. But the way it is, it doesn’t explain anything, doesn’t set any example, so it could be improved. Not to mention that you are basing most of the response on an external link, but if in the future this link fails to work, your answer loses its usefulness, so the importance of detailing at least the minimum!

  • Ready-made, edited post =)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.