5

I had a remote tracking branch named origin/topic. I never created a local branch for it, however, it exists locally because it's a remote tracking branch.

I deleted it:

$ git push --delete origin topic

Now I need to restore that branch. Since it existed as a local remote tracking branch, it should exist in garbage collection somewhere right?

I need to find the tip commit on that branch by log message (I need to grep its log message). I do not have the SHA1 since it was not printed during the push.

How can I recover this branch when the only way of identifying it is its log message?

I'm using Git v2.4

I did review this SO question, but I wasn't able to find any answers there that helped. Specifically, when it came to searching for the commit from log message when the SHA1 is unknown.

Community
  • 1
  • 1
void.pointer
  • 24,859
  • 31
  • 132
  • 243
  • I believe that you can use git reflog (http://git-scm.com/docs/git-reflog) or something like this (http://stackoverflow.com/questions/5543280/how-do-i-get-the-deleted-branch-back-in-git). I've never had to do this, so I can't provide exact details. – Jarred Olson Aug 13 '15 at 17:54
  • You can review http://stackoverflow.com/questions/16398501/how-to-undelete-a-branch-on-github for some ideas. – Daniel Burgner Aug 13 '15 at 17:54

0 Answers0