Recovering a Deleted Branch
In this episode, we'll try to recover a deleted branch.
Transcript
In this episode, we’ll try to recover a deleted branch. Using the “Reflog” tool in Git, we have quite a good chance of undoing this.
Let’s look at an example scenario. Here, we have a “feature/login” branch that contains a valuable commit. Still, we decide to delete the branch - maybe because we were told that the feature isn’t necessary anymore.
But…. well… shortly after deleting it, we realize that we need it back!
Let’s use a Git tool called “Reflog” to see if we can save the day. In case this doesn’t show up in your sidebar, then make sure the Reflog is activated in Tower’s settings.
Think of the Reflog as a journal that keeps track of every movement of the HEAD pointer - when you’re doing a checkout, commit, reset, cherry-pick…
And maybe you remember: we just performed a “checkout” because we had to move to the “master” branch before deleting the feature branch. So right at the top, we have this checkout we just performed. And in order to undo deleting that feature branch, we can simply return to the state before that action.
Now, all we have to do is right-click the state we want to return to and choose to create a new branch on that commit.
Course outlineEpisode 10 of 17
- Discarding All Local Changes in a File
- Restoring a Deleted File
- Discarding Chunks / Lines in a File
- Discarding All Local Changes
- Fixing the Last Commit
- Reverting a Commit in the Middle
- Resetting to an Old Revision
- Resetting a File to an Old Revision
- Recovering Deleted Commits
- Recovering a Deleted Branch
- Moving a Commit to a New Branch
- Moving a Commit to a Different Branch
- Editing Old Commit Messages
- Deleting Old Commits
- Squashing Multiple Commits into One
- Adding a Change to an Old Commit
- Splitting / Editing an Old Commit