Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git checkout failing because branch already exists

I am trying to checkout a branch that I was checking out with success in the past, and I can't check it out anymore. Here are the different messages I am getting. The easy solution would be to reset my folder, do a git init and git clone, but I do not want to reset my git folder as I set up things like git hooks (post-checkout, post-merge, etc). How could I get this to work again without resetting everything?

fatal: A branch named 'stage' already exists.

git fatal: reference is not a tree

error: refs/heads/stage does not point to a valid object!

fatal: bad object stage

like image 692
vintagexav Avatar asked Sep 03 '25 15:09

vintagexav


1 Answers

The way to solve this in a clean way is to delete your corrupted branch in .git/refs/heads/your_branch_name.

like image 106
vintagexav Avatar answered Sep 05 '25 12:09

vintagexav