I deleted a branch with :
git branch -d branch_name
And I pushed, but when I list the branches with :
git branch -avv
I see that the branch is always present with the name remotes/origin/branch_name
.
How can I delete the branch from there?
Steps to delete remote Git branches Issue the git push origin –delete branch-name command, or use the vendor's online UI to perform a branch deletion. After the remote branch is deleted, then delete the remote tracking branch with the git fetch origin –prune command.
Instead of using the git branch command that you use for local branches, you can delete a remote branche with the git push command. Then you specify the name of the remote, which in most cases is origin . -d is the flag for deleting, an alias for --delete . remote_branch_name is the remote branch you want to delete.
They're unnecessary. In most cases, branches, especially branches that were related to a pull request that has since been accepted, serve no purpose. They're clutter. They don't add any significant technical overhead, but they make it more difficult for humans to work with lists of branches in the repository.
Removing a remote repositoryUse the git remote rm command to remove a remote URL from your repository. The git remote rm command takes one argument: A remote name, for example, destination.
When you delete a branch with git branch -d branch_name
you just delete the local one. Push will not affect the status of the remote, so origin/branch_name will remain. If you want to delete it you should do git push <remote_name> --delete <branch_name>
as explained in the post suggested as duplicate.
When someone else delete a branch in the remote (origin) a ref to it will be present in your local repository, so after a pull or fetch you will still see origin/branch_name
. To delete this ref you have to fetch with --prune.
git fetch --prune
If you want you can also combine it inside the pull command.
git pull --prune
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With