Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 277
Programmer Avatar asked Nov 10 '17 05:11

Programmer


People also ask

How do I delete a local and remote branch?

So, to delete the remote branch AND locally-stored remote-tracking branch in one command, just use git push origin --delete <branch> . Then, you just need to delete the local branch with git branch -D branch . That covers the deletion of all 3 branches with only 2 commands.

How do I delete a local branch without deleting the remote?

Unlike local branches, you can't delete a remote branch using the git branch command. However, you need to use the git push --delete command, followed by the name of the branch you want to delete.

How do I delete a local branch in Visual Studio?

Visual Studio 2017 provides you easy access to both. To delete a local branch, right click on it and select Delete from the context menu. To delete a remote branch listed under the remotes/origin, right click on the desired branch and select Delete Branch From Remote from the context menu that pops up on the screen.

What happens if I delete a local branch?

It is safe to delete your local branch after you pushed your changes to your own remote repository. The pull request is unrelated to this, because it is simply a request to the maintainers of the original repository to merge your changes back into their code base.


1 Answers

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 
like image 146
Nandu Kalidindi Avatar answered Sep 21 '22 07:09

Nandu Kalidindi