0

I was trying to make a current branch the master and keep masters history by following this:

git checkout better_branch
git merge --strategy=ours master    # keep the content of this branch, but record a merge
git checkout master
git merge better_branch

but somewhere along the line I messed up and before checking I deleted the better branch (moronic I know). Now I have the commit number of the branch I deleted in the state I wanted it but i dont know if/how I can bring it back. I did a git reset --hard 7585773 but it only reset master(i think). Is there anyway to get my branch back or make master have that branches changes or have I lost them?

this is my git log

commit 758577310015683cd2de688afe0aeb0638eef507
Author: Regan <xxxxxx@gmail.com>
Date:   Tue Mar 3 11:10:19 2015 -0800

    add angular files, setup config file, add backstrech
ReganPerkins
  • 1,645
  • 3
  • 17
  • 36
  • possible duplicate of [Can I recover branch after its deletion in git?](http://stackoverflow.com/questions/3640764/can-i-recover-branch-after-its-deletion-in-git) – Klas Mellbourn Mar 03 '15 at 19:46
  • if this is a duplicate question, and the linked answer worked should I delete my question? – ReganPerkins Mar 03 '15 at 19:52
  • Not necessarily. The different way of formulating the question might helps others to eventually find the original question. – Klas Mellbourn Mar 03 '15 at 20:44

1 Answers1

1

I think that if you consult with this StackOverflow post Recover deleted branch git then you will be able to recover your branch, or possibly this post because the other is marked as a duplicate: Can I recover branch after its deletion in git?

Yes, you should be able to do git reflog and find the SHA1 for the commit at the tip of your deleted branch, then just git checkout [sha]. And once you're at that commit, you can just git checkout -b [branchname] to make a recreate the branch from there.

Using this command: git checkout -b <branch> <sha>

Community
  • 1
  • 1
freddiev4
  • 2,501
  • 2
  • 26
  • 46