The SVN (Subversion) is used to manage the current and previous versions of data like source code, documentation, and files. It acts as the time machine for the developers and allows them to go back and browse the history of the project.
SVN operations can be performed through the command line as well as SVN clients also. Most people love the command line option. So let's understand the essential SVN commands.
Before running the SVN commands, we must have an idea about what is working copy. Let's understand it.
SVN Working Copy
A working copy is a copy that has been checked out to the staging area.
SVN is a version control system that holds all our project versions (Versioned data). It is also called an SVN server. SVN client tools manage the local reflection of the working copy. SVN client is used for accessing its repository across networks. Multiple users can access the same repository at the same time.
Here we are going to list the most used SVN commands that every developer should know.
Most used SVN commands
Some most useful SVN commands are as follows:
Let's understand these commands in detail.
SVN Checkout Command
The svn checkout command is used to create the working copy of the SVN project. The checkout operation is needed to be performed once after each change occurs in the directory structure. If the directory structure is changed, we may need to re-check out it. This command will be executed as follows:
The URL path is the path for the files and repositories. If the PATH is omitted, the default name of the URL will be used as the destination. If multiple URLs are given, each will be checked in the subdirectory of PATH. In these paths, the name of the subdirectory is the base of the URL.
SVN Add Command
The svn add command is used to add the files in the repository for the SVN. Whenever we create a new file in our working copy, we have to send it to the SVN server. This command will be executed as follows:
Remember, this file will be visible after an SVN commit.
SVN Delete Command
The svn delete command is used to remove the files from the repository. When we perform a delete operation, it removes the file from the working. To delete it from the repository, run a commit command after the delete command.
The svn delete command will be executed as follows:
To remove it from the repository, run the commit command as follows:
SVN Commit Command
The svn command is used to save the changes made on the repository. Whenever we made changes on our working copy and want to reflect it on the SVN server. In such a case, we have to make a commit operation.
The commit command will be executed as follows:
The commit message is a message for the audience that we are making changes on the project.
SVN Diff Command
The svn diff command is used to display the differences between two versions of files. We can find the differences between the working copy and the remote (SVN) copy. We can also find the two revisions, paths, and more.
The diff command will be executed as follows:
SVN Status Comman
The svn status command displays the status of the working copy. It shows the status whether the repository is updated, added/deleted, or file is not under revision control and more.
This command will be executed as follows:
SVN Log Command
SVN stores all the history of the project. The svn log command is used to display all the commits made on the repository or file.
The svn log command is executed as follows:
SVN Move Command
The svn move command is used to move the files from the working directory. However, these files can be sent to the SVN server by commit operation.
To move the file, run the below command:
The above command will move the file to the targeted destination. Commit the file to make the changes on the repository.
SVN Rename Command
The svn rename command is used to rename the files. This command will be executed as follows:
SVN List Command
The svn list command is used to display the content of the repository. It is useful in the case; you want to view the details of the repository without making a working copy.
The above command will display the files of the repository without downloading it.
The svn list command with the verbose option will provide more description of files. It will display the revision number of the last commit, Author, size, date, and time of the last commit.
SVN Update Command
The update command is used to update the working copy of the project. It brings the changes from the working copy to the repository. It matches the working copy with the HEAD by default.
It is also used in the case when changes are made by the other users; we have to update the repository.
The update command will be executed as follows:
SVN Info Command:
The svn info command provides a quick look at the working copy. It is accessible in the local working copy, and it does not communicate with the SVN server.
The info command will be executed as follows:
The above command will provide useful information about the repository.
SVN Merge Command
It is used to apply two differences between two sources to a working path.
The above command will merge the changes to the same destination.