You are currently viewing SVN Commands Step by Step

SVN Commands Step by Step

  • Post author:
  • Post category:SVN
  • Post comments:0 Comments
  • Post last modified:February 23, 2024

Tutorial:

SVN (Subversion) is a version control system used to manage files and directories over time. It allows you to track changes in your project, revert to previous versions, and collaborate with other developers. In this tutorial, we’ll cover the basic SVN commands step by step.

Prerequisites

Before getting started, ensure you have SVN installed on your system. You can download and install SVN from the official website.

Step 1: Setting Up a Repository

  1. Create a new directory for your SVN repository:
mkdir svn_repo
  1. Initialize the repository:
svnadmin create /path/to/svn_repo

Step 2: Importing a Project to SVN

  1. Navigate to your project directory:
cd /path/to/your/project
  1. Import your project to the SVN repository:
svn import . file:///path/to/svn_repo/project_name/trunk -m "Initial import"

Step 3: Checking Out a Working Copy

  1. Create a directory for your working copy:
mkdir project_working_copy
  1. Check out a working copy from the SVN repository:
svn checkout file:///path/to/svn_repo/project_name/trunk project_working_copy

Step 4: Making Changes

  1. Navigate to your working copy directory:
cd project_working_copy
  1. Make changes to your files.

Step 5: Adding Files

  1. To add new files to the repository, use:
svn add filename
  1. To add all unversioned files, use:
svn add *

Step 6: Committing Changes

  1. Commit your changes to the repository:
svn commit -m "Description of changes"

Step 7: Updating Your Working Copy

  1. Update your working copy to reflect changes from the repository:
svn update

Step 8: Viewing Status

  1. View the status of files in your working copy:
svn status

Step 9: Reverting Changes

  1. To revert changes to a file:
svn revert filename

Step 10: Resolving Conflicts

  1. If conflicts occur during update or merge, resolve them manually or using a merge tool.

Step 11: Branching and Merging (Optional)

  1. To create a branch:
svn copy ^/project_name/trunk ^/project_name/branches/branch_name -m "Creating a branch"
  1. To merge changes from a branch to trunk:
svn merge ^/project_name/branches/branch_name

Step 12: Viewing Log

  1. View the commit history of a file or directory:
svn log filename

Conclusion

SVN provides a powerful set of tools for collaboration and version control. Explore further to master advanced SVN features and optimize your development workflow.

Leave a Reply