Aaaahhhh I just deleted a branch in Git before merging it back into development

Okay I just deleted a feature branch before merging it back into the development branch. What to do? Lucky I had already committed the changes to the feature branch which made recovery very simple.

If you know the last commit message of the deleted branch you can do this:

git reflog

Search for the commit message:

fd0e4da HEAD@{14}: commit: This is the commit message I want

Checkout the revision:

git checkout fd0e4da

Recreate the committed branch:

git branch -b my-recovered-branch

Now merge it into the development branch. Pfffff, saved my day.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s