Deleting an SVN branch
Solution 1
Sure: svn rm
the unwanted folder, and commit.
To avoid this situation in the future, I would follow the recommended layout for SVN projects:
- Put your code in the
/someproject/trunk
folder (or just/trunk
if you want to put only one project in the repository) - Created branches as
/someproject/branches/somebranch
- Put tags under
/someproject/tags
Now when you check out a working copy, be sure to check out only trunk
or some individual branch. Don't check everything out in one huge working copy containing all branches.1
1Unless you know what you're doing, in which case you know how to create shallow working copies.
Solution 2
For those using TortoiseSVN, you can accomplish this by using the Repository Browser (it's labeled "Repo-browser" in the context menu.)
Find the branch folder you want to delete, right-click it, and select "Delete."
Enter your commit message, and you're done.
Solution 3
Assuming this branch isn't an external or a symlink, removing the branch should be as simple as:
svn rm branches/< mybranch >
svn ci -m "message"
If you'd like to do this in the repository then update to remove it from your working copy you can do something like:
svn rm http://< myurl >/< myrepo >/branches/< mybranch >
Then run:
svn update
Solution 4
You can also delete the branch on the remote directly. Having done that, the next update will remove it from your working copy.
svn rm "^/reponame/branches/name_of_branch" -m "cleaning up old branch name_of_branch"
The ^
is short for the URL of the remote, as seen in 'svn info'. The double quotes are necessary on Windows command line, because ^
is a special character.
This command will also work if you have never checked out the branch.
Solution 5
Command to delete a branch is as follows:
svn delete -m "<your message>" <branch url>
If you wish to not fetch/checkout the entire repo, execute the following command on your terminal:
1) get the absolute path of the directory that will contain your working copy
> pwd
2) Start svn code checkout
> svn checkout <branch url> <absolute path from point 1>
The above steps will get you the files inside the branch folder and not the entire folder.
GSto
Programmer, Musician, and all around nice guy. Currently a developer for J House Media, do some of my own stuff as well over at Chromand. I'm also working towards a degree in Computer Science from the University of Georgia in my free time.
Updated on June 17, 2021Comments
-
GSto almost 3 years
I created a branch of an SVN project called 'features', and now whenever I try to update said project, it brings with it a features folder, which contains another copy of the project from the branch.
Is there a way to remove the branch from the repository completely so that this doesn't happen any more?