Introduction to Subversion via CentOS Command Line
What is Subversion?
Subversion is a software version control system, allowing users to keep track of when and why changes occur to open source code. Code is stored in a directory structure called a repository. Changes to files and directories within a subversion repository are commited, resulting in a new version of the software which can be easily checked out by other users implementing that repository.
Subversion is available in many linux distros (as well as Windows). This article focuses on using subversion via SSH in CentOS.
The subversion homepage is:
http://subversion.apache.org/
This basic tutorial covers installing subversion, creating a repository, importing projects, checking out your repository, and committing revisions to the repository.
Installation
Here is the command you will want to run via SSH when logged in as root:
Creating a Repository
- Change your current directory to where you want to create your repository. In this example, we'll use /home/repo/ as our working repository directory. This is the directory that subversion will use to store information about your projects.
- The 'svnadmin' command is used to create the repository. In the following example, 'mysvn' is the name of our repository. You can name your repository whatever you would like.
svnadmin create mysvn
Importing Projects
- Projects are imported and managed within the repository created above.
- Importing a project requires a directory within your repository. Let's make that directory now using the 'svn' command. Note - you should replace the path in the below command with the actual path to your repository and new project name.
- Subversion will open your Operating System's default text editor, where you will log an explanation of what you are doing, what changes you're making, etc. After completing your log entry, save and exit the editor.
Note: /home/repo/mysvn/myproject has not yet been created in your Operating System's directory structure. It is only available in your repository.
- Import project files using the svn import command:
- Files in your project are imported into the 'myproject' directory within your repository.
Checkout and Commit
- To make revisions to your project files, a working copy of your project must be checked out of the repository. For this, we use 'svn checkout':
- The repository and all revisions are now checked out. A new directory containing your project's files is now available in your OS directory structure. To view them, simply change to your project's directory:
- You can now make revisions to your project's files. When you are finished, and you're ready to store your new revision into your repositoiry, run 'svn commit' from your project's directory:
- Subversion will again open your Operating System's default text editor where an explanation of your revision are logged. Save and exit the text editor when you are finished.
- Your revision is now committed to your repository. Other users can now implement the revisions that you made to your software.