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.

Advertisements

Leave a Reply

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

WordPress.com Logo

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s