Delete a local development branch

I have recently cloned a repo of our development code branch in my system:

git clone https://gitserver.com/product

After the clone was successful I get the below status on query:

$ git branch
* develop

I realized that now this branch needs to be deleted, hence:

$ git checkout develop
Already on 'develop'
Your branch is up-to-date with 'origin/develop'.

$ git branch -d develop
error: Cannot delete branch 'develop' checked out at 'C:/work/test'

I am not sure whether we should try a GIT command or Unix command 'rm -rf' to delete a local develop branch repository? Lastly why no one can delete 'develop' branch.


You cannot delete the branch you are currently on.

Try creating a new branch

git checkout -b new-branch

Then delete the develop branch

git branch -d develop

Adding to Nandu Kalidindi's answer:

When you clone a repo, it will always have a master branch. This master branch, shouldn't be deleted. And if you want to delete it anyway, you must push another branch before, so git will recognize the new pushed branch as the new master branch.

So, in your case, if you want to delete the repo you should try a UNIX command (rm -rf).