Remove svn-branch via git?

I use git as the scm of choice, but should use svn-repo. I can create svn-remote-branch as follows:

git svn branch the_branch 

But how can I delete a remote branch?

+57
git git-svn
Dec 03 '09 at 12:30
source share
4 answers

It is currently not possible to remove the SVN branch using git-svn. But deleting a branch using SVN is easy without even checking it. Just enter

 svn rm $URL/branches/the_branch 

Note that deleting a Subversion branch does not remove it from the git-svn repository. (This is intentional, since deleting the Subversion branch does not lead to loss of information, while deleting the git branch makes it forget its existence after the next git garbage collection.) Therefore, if you want the remote SVN branch to be deleted from the git repository, you should do this is manual:

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

To remove the git branch that matches the Subversion tag, the commands are slightly different:

 git branch -D -r tags/the_tag rm -rf .git/svn/tags/the_tag 
+77
Dec 03 '09 at 13:18
source share
— -

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

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

Not sure about tags, since I don't use them a lot.

+6
Nov 09 2018-10-18
source share

Opps, the top answer was written in 2009, now the correct way to remove the deleted tag

 svn rm svn://dev.in/branches/ios_20130709150855_39721/ git branch -d -r ios_20130709150855_39721 
+2
Oct. 15 '13 at 3:00
source share

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

As described in other answers, follow these steps:

  • $ git log -1 $commit
  • Find the git-svn-id: $url message in the commit message
  • $ svn rm $url

I was too lazy to do this and make an alias:

 [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" 
0
May 18 '17 at 9:35 a.m.
source share



All Articles