Recovering a deleted unlinked branch

I found some solutions on how to restore git branches using

I cannot get some commits from a remote branch or any history of deleting this branch.

The local branch has not yet been merged in my main branch and accidentally deleted. Is it possible to restore it? Thank you for your help!

+4
source share
1 answer

You can start with:

git reflog | grep 'to branchname'

This will match the reflog line as shown below:

219daf7 HEAD@{20}: checkout: moving from master to branchname

git checkout 219daf7, , , tig , tig 219daf7, . ( , git checkout , tig .)

, , , , :

git checkout -b branchname 219daf7

fsck:

git fsck --full --no-reflogs --unreachable --lost-found | grep commit

:

unreachable commit 219daf70a24e635cd95c1493c341585bbf64a61d

, .

+6

Source: https://habr.com/ru/post/1543931/


All Articles