Linux Comm Svn
[ Linux Command Manual](#)
* * *
SVN (Subversion) is an open-source version control system used to manage the change history of files and directories. It helps development teams collaborate on projects, track code changes, and supports version rollback.
Analogy: You can think of SVN as a time machine that records every modification of each file in your project, like save points in a game. You can return to any previous version at any time.
* * *
## SVN Basic Concepts
### Repository
An SVN repository is where all version data is stored, equivalent to a central database. It maintains the complete history of the project.
### Working Copy
This is your local copy of the project where you can make modifications, then commit the changes to the repository.
### Revision
Each commit generates a globally unique revision number to identify a specific state of the project.
* * *
## SVN Installation and Configuration
### Installing SVN
On most Linux distributions, you can install via the package manager:
## Examples
# Ubuntu/Debian
sudo apt-get install subversion
# CentOS/RHEL
sudo yum install subversion
# Fedora
sudo dnf install subversion
### Verify Installation
svn --version
* * *
## Common SVN Commands Explained
### Checkout
Retrieve code from the SVN repository to local:
## Examples
svn checkout
# Example:
svn checkout http://svn.example.com/svn/project/trunk myproject
Common options:
* `--username`: specify username
* `--password`: specify password
* `--non-interactive`: non-interactive mode
### Update
Synchronize the local working copy with the latest version in the repository:
## Examples
svn update
# Update to a specific version
svn update -r 1234
### Commit
Submit local modifications to the repository:
svn commit -m "commit message"
### Status
Check the modification status of the working copy:
svn status
Status flag descriptions:
* `A`: added file
* `M`: modified file
* `D`: deleted file
* `?`: unversioned file
* `!`: missing file
### Add
Add new files to version control:
## Examples
svn add filename
# Add all new files in current directory
svn add --force .
### Delete
Remove files from version control:
svn delete filename
### Log
View commit history:
## Examples
svn log
# View log for specific file
svn log filename
# Limit displayed entries
svn log -l 10
### Diff
View modification contents:
## Examples
# Compare working copy with base version
svn diff
# Compare two versions
svn diff -r 100:200
### Revert
Discard local modifications:
## Examples
svn revert filename
# Revert all modifications
svn revert -R .
### Resolve
Conflicts may occur when multiple people modify the same file:
## Examples
# View conflicted files
svn status
# Mark as resolved after resolving conflict
svn resolve --accept working conflicted_file
* * *
## Advanced Operations
### Branching and Merging
## Examples
# Create branch
svn copy sourceURL targetURL -m "create branch message"
# Merge branch
svn merge sourceURL[@version] working_copy_path
### Tag Management
## Examples
# Create tag (same syntax as creating branch)
svn copy http://svn.example.com/svn/project/trunk
http://svn.example.com/svn/project/tags/1.0
-m "create version 1.0 tag"
### Property Management
## Examples
# Set property
svn propset svn:keywords "Date Rev Author" filename
# View property
svn propget svn:keywords filename
* * *
## Practical Tips
1. **Ignore files**: Create `svn:ignore` property to exclude files that don't need version control
svn propset svn:ignore "*.log" .
2. **View file details**:
svn info filename
3. **Export clean copy** (without .svn directory):
svn export repositoryURL local_directory
4. **Clean up working copy**:
svn cleanup
* * *
## Common Problem Solving
### Authentication Failure
## Examples
# Delete saved authentication information
rm -rf ~/.subversion/auth/
### Working Copy Locked
svn cleanup
### Conflict Resolution Process
1. Update working copy: `svn update`
2. Manually resolve conflict (edit file)
3. Mark as resolved: `svn resolve --accept working filename`
4. Commit modification: `svn commit -m "resolve conflict"`
* * *
## Best Practices
1. Update working copy before committing
2. Write meaningful commit messages
3. Commit small changes frequently, rather than committing large amounts of modifications at once
4. Use branches for feature development
5. Regularly backup the repository
* * *
## SVN vs Git Comparison
| Feature | SVN | Git |
| --- | --- | --- |
| Architecture | Centralized | Distributed |
| Speed | Slower | Faster |
| Branch/Merge | More complex | Simple and efficient |
| Offline work | Limited support | Full support |
| Learning curve | Gentler | Steeper |
* * *
## Summary
SVN is a powerful and stable version control system, particularly suitable for projects requiring strict access control and centralized management. By mastering these basic commands and concepts, you are already able to efficiently use SVN for daily version control work. Remember, the core of version control is frequent commits and good commit habits, which will provide a reliable safety net for your project development.
* * Linux Command Manual](#)
YouTip