How to Create Multiple Branches for Multiple Developers in SVN
Recently, my sir asked me to work on an SVN (Subversion) setup for our project.
The requirement was simple:
👉 Every developer should have their own branch in SVN, and later the admin (team lead) should be able to merge their changes into the main trunk.
At first, I was confused — I only knew Git. But after some research, I realized SVN is also a Version Control System (VCS), just like Git, but it follows a centralized approach. If you are facing the same issue, this guide will help you set up SVN for multiple developers.
If you're in the same boat, this guide will walk you through setting up SVN for a team of developers.
Project Scenario
Let's imagine we're working on a project called Eresource. We have a team of three developers and one admin.
- Developers: Orendra, Vishnu, and Harsh
- Admin: The team lead who manages the main code.
Step 1: Admin Creates the SVN Repository
The first thing the admin needs to do is set up the central "code locker" on their computer. This will be the main repository.
Import your existing project into the trunk: This puts your project's initial codebase into the repository's main folder.Bash
svn import E:\xampp\htdocs\eresource file:///C:/svn_repo/eresource-repo/trunk -m "Importing Eresource project"
Create the standard SVN folder structure: Every SVN repository needs a trunk, a branches folder, and a tags folder. The trunk is for the main, stable code. The branches folder is where developers will work on new features.Bash
svn mkdir -m "Creating folder structure" ^
file:///C:/svn_repo/eresource-repo/trunk ^
file:///C:/svn_repo/eresource-repo/branches ^
file:///C:/svn_repo/eresource-repo/tags
Create a folder for the SVN repo:Bash
mkdir C:\svn_repo
svnadmin create C:\svn_repo\eresource-repo
Step 2: Create Developer Branches
Once the project is in the trunk, the admin needs to create a separate branch for each developer. This allows them to work on their tasks without affecting the main code.
Bash
svn copy file:///C:/svn_repo/eresource-repo/trunk file:///C:/svn_repo/eresource-repo/branches/orendra -m "Creating Orendra branch from trunk"
svn copy file:///C:/svn_repo/eresource-repo/trunk file:///C:/svn_repo/eresource-repo/branches/vishnu -m "Creating Vishnu branch from trunk"
svn copy file:///C:/svn_repo/eresource-repo/trunk file:///C:/svn_repo/eresource-repo/branches/harsh -m "Creating Harsh branch from trunk"
Step 3: Developers Get to Work (Checkout)
Now, each developer can create their own "working copy" by checking out their specific branch. This pulls a copy of the code from the central repository to their local machine.
Bash
svn checkout file:///C:/svn_repo/eresource-repo/branches/orendra C:\svn_working\orendra
svn checkout file:///C:/svn_repo/eresource-repo/branches/vishnu C:\svn_working\vishnu
svn checkout file:///C:/svn_repo/eresource-repo/branches/harsh C:\svn_working\harsh
👉 Example (Harsh making a change): When a developer makes a change, they can use svn status to see which files they’ve modified. After saving the changes, they can commit them back to their branch.
Bash
svn status
# M resources/views/welcome.blade.php
svn commit -m "Harsh: Fixed login page bug"
The M means the file has been "Modified." The commit sends the changes to the central repository.
Step 4: Admin Merges Changes into the Trunk
When a developer finishes their work, the admin is responsible for merging the changes from the developer's branch into the main trunk.
Commit the merged changes: Once everything looks good, the admin commits the merged changes to the central repository's trunk.Bash
svn commit -m "Merged Harsh's changes into trunk"
Merge the branch changes: This command pulls all the new code from the developer's branch into the admin's local copy of the trunk.Bash
svn merge file:///C:/svn_repo/eresource-repo/branches/harsh
svn status
Go to the trunk folder:Bash
cd C:\svn_working\trunk
Step 5: LAN Access (Real Collaboration)
The commands above use local paths, which is great for a single computer. For a team on a LAN, you'll need to use the admin's IP address to access the central repository.
Developer checkout using IP:
Bash
svn checkout svn://10.20.41.81/eresource-repo/branches/orendra C:\svn_working\orendra
svn checkout svn://10.20.41.83/eresource-repo/branches/vishnu C:\svn_working\vishnu
svn checkout svn://10.20.41.87/eresource-repo/branches/harsh C:\svn_working\harsh
Admin merges using TortoiseSVN: Instead of using the command line, the admin can use the TortoiseSVN graphical interface to merge.
- Right-click on the trunk folder.
- Go to TortoiseSVN → Merge.
- Choose “Merge a range of revisions”.
- In the “URL to merge from” field, enter the developer’s branch URL (e.g.,
svn://10.20.41.81/eresource-repo/branches/harsh).
Final Workflow
Your team is now set up to use SVN! Each developer can work in their own branch, and the admin can manage and merge the final code into the main trunk.
If you have any more questions, feel free to reach out.