In today’s article, we are going to show you how to install Subversion on a Linux VPS, as well as some basic Subversion commands. Subversion, or for short SVN is open source version control and version control software. This allows users to maintain current and historical versions of files, such as source code, web pages, documents, and other electronic data.
First of all, install SVN on Linux
In order to install SVN, you need to connect to the Linux VPS via SSH.
If you are using Ubuntu, update your OS packages and install SVN on the server using the following commands:
sudo apt-get update sudo apt-get install svn
If you are using CentOS, you can use the following command to update OS packages and install SVN:
yum update yum install svn
To check the SVN version installed on your server, use the following command:
# svn --version svn, version 1.7.14 (r1542130)
Create a system user account and switch to that user:
useradd -M someuser
Replace ‘someuser’ with a valid username.
su someuser cd ~
Create a new directory for your project / application / website files:
mkdir -p svn/myapp
Create SVN repository using the following command:
sudo svnadmin create /home/someuser/svn/myapp
Set the appropriate file permissions. Debian based distributions, run the following command:
chown -R www-data:subversion myapp chmod -R g+rws myproject
For RPM based distribution (when using Apache as your web server), run the following command:
chown -R apache:subversion myapp chmod -R g+rws myproject
Create a ‘passwd’ file in the / home / someuser / svn / myapp / conf / passwd directory on the server that contains user authentication information:
sudo htpasswd -c /home/someuser/svn/myapp/conf/passwd someuser
If you want to add users, use the same command, but without the ‘-c’ switch, to avoid overwriting the passwd file.
Assigning permissions for SVN users using the authz file (/ home / someuser / svn / myapp / conf / authz):
Create the conceptual groups that you need and then add users to it:
[groups] allaccess = someuser someaccess = someuser2
Select access level from both permissions and project level:
To give read and write “allaccess” permissions to users, add:
[/] @allaccess = rw
To give read-only access to “someaccess” users to some down-level project, add:
[/someproject] @someaccess = r
To copy the unversioned tree of your project / website files and start tracking in your SVN repository and creating intermediate directories, enter the following commands:
svn import -m "Initial import" local/path/ https://svn.yourdomain.com/path/to/svn/repo/
You can create a single repository for each project / site in some central place where the whole story is. To create a working copy to a different local directory, use:
svn co https://svn.yourdomain.com/path/to/svn/repo/ /local/path/directory2
To push changes from a working copy to the repository, use:
svn commit -m "добавьте краткую информацию об изменениях здесь">
Use the ‘svn add / path / file’ command to add a file from the working copy to the repository). The file will be added to the repository when you commit to SVN.
To remove a file from your working copy (or repository) use:
svn delete /path/file
and the file will be removed from the repository after svn commit command.
To update changes from repository to working copy use:
If you have multiple authors working on a project / website and have local working copies on multiple machines, always run the ‘svn update’ command before making changes to the files available in your working copy. After that, make changes to the files, and then commit the changes to the repository after the files are changed.
To apply the differences between the two sources to the working copy path, use:
To see the differences between these two specific versions of a file, use:
svn diff -r revision1:revision2 filename