Shaoz
Shaoz

Reputation: 10653

In Git, I get an error when I try to delete my local branch

I looked around SO, but couldn't find any answer with the error I have.

I created a new branch but I forgot to do something before hand, so I need to delete the new branch I just created from my local machine. The issue is, when I do git branch -d <branch_name> I get this error: Cannot delete the branch <branch_name> which you are currently working on.

But I'm not doing anything in it, I just want to delete it.

What are the steps to follow to delete a local branch and for the error not to come up again?

Many Thanks

Upvotes: 1

Views: 145

Answers (1)

SLaks
SLaks

Reputation: 887215

You cannot delete the current branch from under your feet.
Before you can delete a branch, you must switch to a different branch:

git checkout other-branch

Upvotes: 6

Related Questions