Importing code files to the repo repository
My code files are stored in/var/www/html/;
The path to the SVN code repository is/application/svndata/repo (the location of the repository we just created);
Execute import command: SVN import/var/www/html/svntest file:///application/svndata/repo-m "Init dir"
2. Export code from repository: SVN co URL directory
Checkout code to the specified directory
Export code to current directory; Execute export command: SVN checkout svn://192.168.1.5/repo/root/test--usrname A--password B--no-auth-cache
3. Submit to Repository from code copy of work
If we do not modify the code, then the submission is meaningless. Let us first modify the next 1.php;
CD test
Vim 1.php
After saving the changes, execute the SVN add 1.php Execution Commit command in the Svntet directory:
svn commit-m "Add dir" svn commit/root/data--username Alex--password Alex--no-auth-cache-m "haha"
4. Updating the code copy of the work from the repository
If there are n people doing the same job, everyone is in the same repository, then maybe your current repository is not up to date. So, we need to update the code copy of the work from the repository.
Execute code:
CD Svntest
SVN update
5.SVN status-Prints the status of working copy files and directories.
We can quickly find newly added files that are not included in version control with SVN status or SVN St.
SVN status-v Test
6.SVN View data: Displays a list of files that exist in a directory or a version
SVN list or SVN ls
[[Email protected] data]# SVN list svn://10.0.0.62/repo/data--username Alex--password Alex--no-auth-cache
The first column represents the state of the file that changed state:
‘?‘ Project is not under version control;
The ' M ' project has been modified;
‘!‘ Project has been lost;
The ' ~ ' item is versioned as an object (file, directory, or link) but has been replaced by another object.
7. We use grep to filter out files or folders that are not under version control
SVN St | Grep?
SVN St | grep? | awk ' {print $} '
We can use awk to get their information one at a time, and now we just need their path, and then there's SVN adding them to version control.
In fact, the outermost layer of the work backup executes the following code to add version control to files or filenames that have not been added to version control
SVN status | grep? | awk ' {print $} ' | Xargs SVN add
Execute the command submitted to repository: SVN commit-m "Add NewFile"
Note: Add version control command: SVN add 3.php 4.php, the repository does not have a newer version. The update will not be submitted until the next execution commit
8. Delete the work copy and repository files
Situation one: First in the working directory copy Delete, the next time you execute the commit command, automatically removed from the repository
1. Execute the Delete command first: SVN del 1.php 2.php
2. Execute the commit command again: SVN commit-m "Delfile"
Scenario Two: Delete directly from the repository and then update under the Working copy (update)
Execute Delete command: SVN del-m "del 4.php" file:///var/svn/svntet/4.php
The. svn file will be present in the working copy in each directory, and how can we quickly remove all. svn files when the project is finished? We can write a shell script to delete it.
Find-type d-name ". SVN" | Xargs RM-RF
9. Update to a version
SVN update-r m path
For example:
SVN update If there is no directory behind it, the default is to update all files in the current directory and subdirectories to the latest version.
SVN update-r test.php (Restore the file test.php in the repository to version 200)
SVN update test.php (updated, sync in Repository.) If the prompt expires at the time of submission, it is because of the conflict, you need to update, modify the file, then clear the SVN resolved, and then commit the commit)
Shorthand: SVN up
Locking/unlock
SVN lock-m "Lockmessage" [--force] PATH
Example: SVN lock-m "lock test File" test.php
SVN unlock PATH
10. View the SVN version number
In SVN's working directory, enter the command: SVN info
11. View all log records modified, including author, date, path, etc.
SVN log path
12. View all modified records for a specific version number
SVN log-v-R n
13. Display row-level details for a specific modification
SVN diff
To compare the differences between the two versions, or to know what changes were made to a version compared to the previous version
Example: SVN diff test.php (compares the modified file to the underlying version)
SVN diff-r m:n Path (difference between version m and version N)
Example: SVN diff-r 2036:2037 test.php
Shorthand: SVN di
14. Merging the differences between the two versions into the current file
SVN merge-r m:n Path
For example: SVN merge-r 200:205 test.php (the difference between version 200 and 205 is merged into the current file, but generally conflicts occur and need to be addressed)
15. Create a new catalog under the included version control
SVN mkdir: Create a new directory under the included version control.
Usage:
1. mkdir PATH ...
2. mkdir URL ...
Create a version-controlled directory.
1. Each directory specified in the working copy PATH will be created on the local side and added
Scheduled to be submitted for the next time.
2. Each directory specified in the URL will be created by submitting it to the repository immediately.
In both cases, all intermediate directories must exist beforehand.
16. Trigger Some commands with the hook file :
For example, we have 3 working copies. We want to implement this feature: two developers, with their own working copy and test environment alone. The 3rd working copy is used to see if a developer commits a conflict with another developer's modified code. To put it simply, whether the working copy is submitted or not, the working copy I specified is automatically updated.
Copy the Post-commit.tmpl under Hooks to post-commit. Add the following code below the Post-commit, depending on the configuration of your machine. Here is an illustration.
[Plain] View plain copy
Export Lang=en_us. UTF-8
Svn=/usr/bin/svn
Web=/var/www/html/test
$SVN up $WEB--username admin--password admin--no-auth-cache
Synchronizing a repository to the current project, or updating the current version to a version in the repository
SVN up-r x Test
This article is from the "Light Dust" blog, please be sure to keep this source http://857803451.blog.51cto.com/12777961/1957253
Summary of common operations commands for SVN under Linux