Retrieving a Deleted Git Branch from Local and Remote Sources

For Solution 3, start by finding out the commit ID. Then, recover the local branch that was mistakenly deleted. If the remote branch was also deleted, you will need to push it again and specify the branch name.
In Solution 4, the deleted branches can still be found in the “remote tracking branches” under “origin/contact_page” and “origin/new_pictures” after being fetched and pushed. To delete a remote branch, use a different command than the one used for local branches.


Is it possible to retrieve my
deleted git
branch? I removed it both from my local repository and
remote repository


Execute the

git reflog

command to locate the sha1 of the commit present at the highest point of
deleted branch
. Once located, simply run

git checkout -b <branch> <sha1>

to complete the task.

Frequently Asked Questions

Posted in Git