0 votes
in Git by
Can you recover a deleted branch in Git?

1 Answer

0 votes
by

Yes, you can. To recover a deleted branch, you should know the SHA off the top of your head. SHA or hash is a unique ID that Git creates with every operation.

When you delete a branch, you get the SHA displayed on the terminal:

Deleted branch <your-branch-name> (was <sha>)

You can use the below command to recover the deleted branch:

git checkout -b <your-branch-name> <sha>

Related questions

0 votes
asked Oct 15, 2019 in Git by rajeshsharma
0 votes
asked Feb 13, 2022 in Git by rajeshsharma
...