Reputation: 2337
I want to delete local branch from git. It shows the delete message but actually it is not deleted. the code is written as follows: I have no idea what is going on this image. Please help me to delete remove-ipsum from local git
git branch -a
git checkout master
git branch -d remove-ipsum
it shows the deletation message as : Deleted branch remove-ipsum (was 870afb1).
git branch -a
but still displaying this branch.
Why this is happens? any solution?
Upvotes: 2
Views: 1975
Reputation: 21908
In short : No problem to solve, your local branch has been deleted successfully.
Why?
Since you got the deletion confirmation message, we now know that the local version of that branch has successfully been deleted.
But git branch -a
displays not only local branches, it also lists remote-tracking branches. So unless the branch was never pushed/pulled, it has a remote-tracking counterpart which hasn't been pruned yet.
So what's left to do?
Either the branch still exists remotely for good reasons, or you can also delete it with
git push <remoteName> :<branchName>
(be sure to notice the space before the ":
", this is very different from <remoteName>:<branchName>
)
or (alternative syntax for completion, but their effect is identical)
git push --delete <remoteName> <branchName>
Warning though, since there's no confirmation on this step : it will delete the branch no matter what, merged or not.
Finally
At this point, both local and remote versions of the branch are gone, and you will still have the branch show up in git branch -a
output. What?! Why?
Because as we mentioned above, the remote-tracking branch, being a local copy of the remote branch (for off-line comparison's sake), hasn't been deleted neither by your first command nor by the one I suggested to you for the remote branch.
So, to prune it from your remote-tracking branches list, now that you've deleted the remote counterpart, you can
git fetch --prune
and it won't show up in git branch -a
output any more.
Upvotes: 6