I screwed up a local branch on my computer by rebasing it to some other branch. I wanted to rebase but I didn't switch to the branch I wanted to rebase, and as a result I screwed up somebranch
. I had no idea how to undo my rebase screwup in somebranch
(if anyone knows it would be good to know for the future) so I decided that since I have somebranch
on github I would just delete it locally and then pull it from github. I don't know what I did but I screwed that up too. Eventually I found what I believe to be the right commands to recreate a deleted local branch by pulling it in from my remote origin:
git fetch origin somebranch:refs/remotes/somebranch
git checkout -b somebranch --track origin/somebranch
In gitk I can see there are three things now:
somebranch, remotes/somebranch, remotes/origin/somebranch
but all my other branches only show a local and one remote. example:
someotherbranch, remotes/origin/someotherbranch
I ran git for-each-ref
and both ref/remotes/somebranch and ref/remotes/origin/somebranch point to the same commit.
My question is what is the difference between the two and how do I get rid of the ref/remotes/somebranch. I tried git update-ref -d remotes/somebranch
but it didn't work.