Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make git-svn get rid of remote branches that don't exist anymore?

Tags:

git

git-svn

Is there a handy way to get my local git repo to forget about remote branches that have been deleted? git svn fetch doesn't "re-sync everything" like I hoped it might. My local repo was set up with using an import of the standard svn repo layout (git svn -s …).

related: Why does git remote not list anything on my git-svn repo?

like image 951
John Bachir Avatar asked Dec 08 '10 05:12

John Bachir


People also ask

How do I delete local branches no longer on my remote?

Remove All Local Branches not on Remote 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.

How do you clean up up local branches and references to non existing remote branches?

In order to clean up remote tracking branches, meaning deleting references to non-existing remote branches, use the “git remote prune” command and specify the remote name. In order to find the name of your current configured remotes, run the “git remote” command with the “-v” option.

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

You can remove orphaned remote branches by executing the following commands:

git branch -d -r my_branch
rm -rf .git/svn/refs/remotes/my_branch

To remove all orphaned branches at once rather than one at a time, see the answer here.

like image 133
Matt Hulse Avatar answered Oct 01 '22 04:10

Matt Hulse