Delete a svn-Branch via git?

GitGit Svn

Git Problem Overview


I'am using git as scm of choice but have to use a svn-repo. I can create a svn-remote-branch like this:

git svn branch the_branch

But how can i delete the remote branch?

Git Solutions


Solution 1 - Git

Currently, it is not possible to delete an SVN branch using git-svn. But it is easy to delete the branch using SVN, without even having to check it out. So simply type

svn rm $URL/branches/the_branch

Please note that deleting a Subversion branch does not cause it to be deleted from the git-svn repository. (This is intentional, because deleting a Subversion branch does not cause any information loss, whereas deleting a git branch causes its existence to be forgotten following the next git garbage collection.) So if you want the remote SVN branch to be deleted from your git repository, you have to do it manually:

git branch -D -r the_branch
rm -rf .git/svn/the_branch

OR
rm -rf .git/svn/refs/remotes/f8745/ (for newer versions)

To delete a git branch that corresponds to a Subversion tag, the commands are slightly different:

git branch -D -r tags/the_tag
rm -rf .git/svn/tags/the_tag

Solution 2 - Git

This worked well for me, thanks. Not sure if my environment is just different or this was changed in a more recent version of git, but the svn branch dirs were located in .git/svn/refs/remotes/ which was simple enough to find from the original instructions, changing the rm command to:

rm -rf .git/svn/refs/remotes/the_branch

Not sure about the tags since I don't use those much.

Solution 3 - Git

Opps, the top answer was wrote at 2009, now the correct way to delete a remote tag is

svn rm svn://dev.in/branches/ios_20130709150855_39721/
git branch -d -r ios_20130709150855_39721

Solution 4 - Git

As of 2017, we still don't have git svn branch --delete. (-d option is there but it is for mystic --destination)

As described in other answers, manual steps are:

  1. Print commit message: git log -1 $commit
  2. In the commit message, locate git-svn-id: $url line
  3. Remove SVN branch: svn rm $url

I made an alias to automate these steps:

[alias]
	svn-rm-branch = "!f() { if git_svn_id=\"$(git log -1 --format=%B \"$@\" | grep -o '^git-svn-id:[^@]*')\" ; then svn rm --editor-cmd=\"$(git var GIT_EDITOR)\" \"$(echo $git_svn_id | cut -d' ' -f 2)\" ; else echo No git-svn-id in the message of the commit \"$(git rev-parse \"$@\")\" 1>&2; fi }; f"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDerKlopsView Question on Stackoverflow
Solution 1 - GitmhaggerView Answer on Stackoverflow
Solution 2 - GitStephen CView Answer on Stackoverflow
Solution 3 - GitalswlView Answer on Stackoverflow
Solution 4 - GitsnipsnipsnipView Answer on Stackoverflow