Recovering a git branch

0 votes
One of my teammates, accidentally deleted a branch and has already pushed the changes to central git repo. There are no other git repos and none of my teammates has a local copy. How to recover that branch?
Nov 26, 2019 in Git & GitHub by anonymous
• 19,610 points
1,316 views

1 answer to this question.

0 votes

Check out the latest commit to this branch in the reflog, and then check it out as a new branch.

  • Reflog is a mechanism to record when the tip of branches are updated. This command is to manage the information recorded in it. Basically every action you perform inside of Git where data is stored, you can find it inside of the reflog.

  • git reflog won't navigate HEAD's progressive system by any stretch of the imagination. The reflog speak to the requested rundown of the submits that HEAD has indicated: it's fixed history for our repo. 

  • The reflog isn't a piece of the repo itself (it's put away independently to the submits themselves) and is excluded in pushes, gets or clones; it's absolutely neighbourhood. you can't generally lose information from your repo once it's been dedicated. 

  • On the off chance that you incidentally reset to a more established submit, or rebase wrongly, or whatever other tasks that outwardly "evacuate" submit, you can utilize the reflog to see where you were previously and git reset - hard back to that ref to reestablish your past state

answered Nov 26, 2019 by Sirajul
• 59,230 points

Related Questions In Git & GitHub

0 votes
1 answer

How to do a re-merge into another branch in git

Seems like you want to rebase your ...READ MORE

answered May 7, 2018 in Git & GitHub by DareDev
• 6,890 points
2,473 views
+1 vote
2 answers

Delete a git branch locally and remotely

Deleting a remote branch: git push origin --delete ...READ MORE

answered Aug 20, 2018 in Git & GitHub by Nilesh
• 7,060 points
3,592 views
+1 vote
1 answer

How do I rename a local Git branch?

Hi@akhtar, You can rename your branch name. Sometimes ...READ MORE

answered Sep 4, 2020 in Git & GitHub by MD
• 95,460 points
759 views
0 votes
1 answer

How to delete a Git branch remotely?

Hi@akhtar, You can delete the branch locally or ...READ MORE

answered Nov 21, 2020 in Git & GitHub by MD
• 95,460 points
771 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,063 views
+2 votes
1 answer
0 votes
2 answers

How to view the nested workflow of a local git repository?

The closest way to view branches in ...READ MORE

answered Aug 2, 2019 in Git & GitHub by Sirajul
• 59,230 points
1,623 views
0 votes
3 answers

What is git rebasing?

HI. Rebase is nothing but a Git utility ...READ MORE

answered Sep 4, 2020 in Git & GitHub by SRI
1,257 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP