Introduction to Subversion via CentOS Command Line: Difference between revisions
Docs admin (talk | contribs) test |
Docs admin (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
==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 committed, 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:<strong><br /></strong> | ||
< | <syntaxhighlight lang="bash">yum install subversion</syntaxhighlight> | ||
< | ==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. | |||
<syntaxhighlight lang="bash"> | |||
cd /home/repo | |||
svnadmin create mysvn | |||
</syntaxhighlight> | |||
==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. You should replace the path in the below command with the actual path to your repository and new project name. | |||
<syntaxhighlight lang="bash"> | |||
svn mkdir file:///home/repo/mysvn/myproject | |||
</syntaxhighlight> | |||
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: | |||
<syntaxhighlight lang="bash"> | |||
svn import file:///home/repo/mysvn/myproject | |||
</syntaxhighlight> | |||
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': | |||
<syntaxhighlight lang="bash"> | |||
svn checkout file:///home/repo/mysvn | |||
</syntaxhighlight> | |||
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: | |||
<syntaxhighlight lang="bash"> | |||
cd /home/repo/mysvn/myproject | |||
</syntaxhighlight> | |||
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: | |||
<syntaxhighlight lang="bash"> | |||
svn commit | |||
</syntaxhighlight> | |||
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. | |||
[[Category:CentOS 5]] |
Revision as of 12:19, 9 October 2012
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 committed, 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:
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:
<syntaxhighlight lang="bash">yum install subversion</syntaxhighlight>
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.
<syntaxhighlight lang="bash"> cd /home/repo svnadmin create mysvn </syntaxhighlight>
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. You should replace the path in the below command with the actual path to your repository and new project name.
<syntaxhighlight lang="bash"> svn mkdir file:///home/repo/mysvn/myproject </syntaxhighlight>
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.
Import project files using the svn import command:
<syntaxhighlight lang="bash"> svn import file:///home/repo/mysvn/myproject </syntaxhighlight>
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':
<syntaxhighlight lang="bash"> svn checkout file:///home/repo/mysvn </syntaxhighlight>
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:
<syntaxhighlight lang="bash"> cd /home/repo/mysvn/myproject </syntaxhighlight>
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:
<syntaxhighlight lang="bash"> svn commit </syntaxhighlight>
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.