Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete remotes/origin/{branch}?

Tags:

git

How do you delete a remotes/origin/{branch}?

like image 627
keruilin Avatar asked Jan 16 '11 01:01

keruilin


People also ask

How do I delete a remote origin branch?

To delete a remote branch, you can't use the git branch command. Instead, use the git push command with --delete flag, followed by the name of the branch you want to delete. You also need to specify the remote name ( origin in this case) after git push .

How do I remove a remote branch code?

Here's the command to delete a branch remotely: git push <remote> --delete <branch> . The branch is now deleted remotely.

How do I delete all remote branches?

Let's break this command: First we get all remote branches using the git branch -r command. Next, we get the local branches not on the remote using the egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) command, Finally we delete the branches using the xargs git branch -d command.


1 Answers

use: git remote prune origin

or use git remote prune origin --dry-run to preview what branches will be removed.

As in git help remote

prune
Deletes all stale remote-tracking branches under . These stale branches have already been removed from the remote repository referenced by , but are still locally available in "remotes/".

With --dry-run option, report what branches will be pruned, but do not actually prune them.

like image 73
Ryan Le Avatar answered Oct 08 '22 13:10

Ryan Le