Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

delete remote branch origin

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?

like image 217
Brahim LAMJAGUAR Avatar asked Aug 22 '18 10:08

Brahim LAMJAGUAR


People also ask

How do you delete a remote branch in origin?

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.

What is the command to delete remote branch?

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.

Should I delete remote branch?

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.

How do I delete a remote git 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.


1 Answers

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
like image 81
ErniBrown Avatar answered Nov 15 '22 06:11

ErniBrown