Retrieve feature from git repository

0

Create a feature for my new project, run some commits, and then push the cloud. I deleted my local feature and I ended up deleting the cloud feature as well.

Would you like to know if you can recover a deleted cloud feature in my git? if so, what procedure should be followed?

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

    
asked by anonymous 19.11.2018 / 19:40

1 answer

0

Imagine a scenario in which you have used a rebase in your branch and lost it in n commits or reset --hard.

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

If you would like to go back to the repo state before rebase or reset --hard, you can use git reflog.

Git internally maintains a state log of your HEAD and any 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 the HEAD state are recorded. When we know which state we want to move the HEAD to,

git reset --hard HEAD@{x}

If you have changes and you can not do a forced restart for a given reflog, but you still want the commit changes to be lost.

git cherry-pick <commit-hash>

    

19.11.2018 / 19:51