Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git: delete remote branch from mirror tree

Tags:

git

I built a repository using

git clone --mirror <url>

I want to remove some remote branches, but I get the following:

$ git push origin :b
error: --mirror can't be combined with refspecs

... or

$ git push --delete b
fatal: --delete doesn't make sense without any refs

Also, git branch -D b does not touch the remote.

Is there a way to remove remote branches from a mirror clone or do I have to build another clone for that?

like image 704
Penz Avatar asked Feb 08 '13 15:02

Penz


People also ask

How do I remove a remote git branch?

Steps to delete remote Git branchesIssue 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.

Does git branch 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.

How do I delete a remote branch that is not local?

How to Delete a Branch Remotely. You'll often need to delete a branch not only locally but also remotely. To do that, you use the following command: git push <remote_name> --delete <branch_name>.

Does git prune delete remote branches?

git fetch --prune is the best utility for cleaning outdated branches. It will connect to a shared remote repository remote and fetch all remote branch refs. It will then delete remote refs that are no longer in use on the remote repository.


1 Answers

In fact, you can delete any branch of any repository without even cloning it:

git push <url> +:refs/heads/b

The only caveat is that you must be inside a git repository, any repository - you can even create an empty repository to do just that and then delete it.

Surely enough, you can do that inside the mirror too, just note that you will only see the branch go away after doing a git remote prune origin.

like image 62
Penz Avatar answered Sep 30 '22 02:09

Penz