Linux installation svn and configuration use

Source: Internet
Author: User
Tags create directory diff svn svn client tortoisesvn

1. Install SVN
apt-get install subversion
2. Build SVN repository

1). Create SVN directory: mkdir /home/.svn (use hidden directory)
2). cd /home/.svn
3). mkdir astar
4). Create Warehouse Astar: svnadmin create /home/.svn/astar after execution, Astar directory has svnadmin directories and files created
5). mkdir test
6). Create Warehouse test: svnadmin create /home/.svn/test After execution is complete, the test directory has svnadmin created directories and files

3. Configure and manage SVN

1). The configuration file for each warehouse under $repos/conf/, vi svnserve.conf, configuration items under [general]:
Anon-access: The permissions for anonymous users can be read,write and none, and the default value is read. Do not allow anonymous user access: Anon-access = None
Auth-access: Authentication user's permission, can be read,write and none, default value of write.
PASSWORD-DB: The path of the password database, remove the front #
AUTHZ-DB: The path of the authentication rule library, minus the # in front.
Note: The lines of these configuration items are shelf, otherwise they will be error-aware. After you modify the configuration, you need to restart SVN to take effect.

2). Configure the passwd file
This is the password file for each user, relatively simple, that is, "User name = password", using the plaintext. such as allen=111111
3). Configure the Authz file
1. [Groups] section: For ease of management, you can put some users into a group inside, such as: Owner=allen,ellen
2. Groups the sections below indicates that the authentication rules for a directory, such as the section of the authentication rule for the root directory, are [/]. Set up single-user authentication rules when a user is on one line, such as:
[/]
ALLEN=RW #allen对根目录的权限为rw
Ellen=r #ellen对根目录的权限为r
If you use group, you need to add @ before the group name, such as
@owner =RW #group owner is RW, equivalent to the two words above
If booting from/home/.svn/astar at startup,/is the Astar directory, set the permissions as above with the Astar directory as the root.
If you start from/home/.svn/, each repository root is your own starting directory. You can set Astar permissions as above, or you can use the following methods:
[astar:/]
@owner =RW
The permissions to set test are as follows:
[test:/]
@harry_and_sally = RW
In short, the root directory (/) of each repository is its own starting directory; [repos:/] This approach applies only to multi-warehouse situations; [/] is suitable for single warehouses and single warehouses.
3. You cannot set permissions across warehouses.

4. Start and Stop SVN

1). Start:
1. Starting from the Astar directory, svnserve-d-r/home/.svn/astar, the root directory (/) is astar,authz in the configuration of the rules using section[/]. Access is as follows:
svn://192.168.0.87/
2. Boot from the. SVN directory, svnserve-d-r/home/.svn, the root directory (/) is the. Svn,authz in the configuration of Astar use section[astar:/], the configuration of test uses section[test:/]. Access is as follows:
Svn://192.18.0.87/astar
Svn://192.18.0.87/test
If you need SVN self-booting, add the command to/etc/rc.local.
2). Check that the SVN server is started (SVN uses 3690 ports by default): Netstat-an | grep 3690
3). Stop: Killall svnserve

5. SVN client

Recommended use of TORTOISESVN, http://tortoisesvn.tigris.org/
Eclipse Plugin, http://subclipse.tigris.org/

7. Client Connection

SVN Co svn://ip/oplinux
User name password: 123456

8. Implement SVN synchronization with the Web, can be a co-or directly in the warehouse

1) Set the Web server root directory to/www/webroot
2) Checkout a copy of SVN

svn co svn://localhost/oplinux /www/webroot

Modify permissions for Web users

chown -R apache:apache /www/webroot/oplinux

3) Create a synchronization script

cd /www/svndata/oplinux/hooks/cp post-commit.tmpl post-commit

Edit Post-commit, add the following at the end of the file

export LANG=en_US.UTF-8SVN=/usr/bin/svnWEB=/www/webroot/$SVN$WEB$WEB

Increase script Execution permissions

chmod +x post-commit

=============================================================================================================== ===============

Client uses command 1, check out

SVN CO/HTTP path (full path to directory or file) [local directory full path]
–username username –password Password SVN co svn://path (full path to directory or file) [local directory full path]–username user name –password password

svn  checkout  http--username 用户名svn  checkout  svn://路径(目录或文件的全路径) [本地目录全路径]  --username 用户名

Note: If you do not transfer the password with the –password parameter, you will be prompted to enter the password, it is recommended not to use the Clear text –password option.
Among them username and password before is two short-term, not one.
Does not specify a local directory full path, it is checked out to the current directory.
Example:

--username wzhnschttp--username wzhnsc--username wzhnsc--username wzhnsc
2. Export (Export a clean directory tree without the. SVN folder)
svn  export  [-r 版本号]  http://路径(目录或文件的全路径) [本地目录全路径] --username 用户名svn  export  [-r 版本号]  svn://路径(目录或文件的全路径) [本地目录全路径] --username 用户名svn  export  本地检出的(即带有.svn文件夹的)目录全路径  要导出的本地目录全路径

Note: The first way to export a clean working directory tree from the repository is to specify the URL,
If a revision number is specified, the corresponding version is exported.
If no revision is specified, the latest export is exported to the specified location.
If the local directory full path is omitted, the last part of the URL is the name of the local directory.
The second form is to specify the local checked-out directory full path to the local directory full path to be exported, and all local modifications will be preserved.
However, files that are not under version control (that is, new files that are not submitted because the. SVN folder does not have information records associated with it) are not copied.
Example:

export svn://localhost/测试工具 /home/testtools --username wzhnscexport svn://localhost/test/testapp --username wzhnscexport /home/testapp /home/testtools
3. Add new files

SVN Add file name
Note: Tell SVN server to add files, but also use SVN commint-m real upload up!
Example:

add test.php <- 添加test.php svn commit -m “添加我的测试用test.php“ test.phpadd *.php <- 添加当前目录下所有的php文件svn commit -m “添加我的测试用全部php文件“ *.php
4. Submit
svn commit -m “提交备注信息文本“ [-N] [--no-unlock] 文件名svn ci -m “提交备注信息文本“ [-N] [--no-unlock] 文件名必须带上-m参数,参数可以为空,但是必须写上-m例子:svn commit -m “提交当前目录下的全部在版本控制下的文件“ * <- 注意这个*表示全部文件svn commit -m “提交我的测试用test.php“ test.phpsvn commit -m “提交我的测试用test.php“ -N --no-unlock test.php <- 保持锁就用–no-unlock开关svn ci -m “提交当前目录下的全部在版本控制下的文件“ * <- 注意这个*表示全部文件svn ci -m “提交我的测试用test.php“ test.phpsvn ci -m “提交我的测试用test.php“ -N --no-unlock test.php <- 保持锁就用–no-unlock开关
5. Update files
svn updatesvn update -r 修正版本 文件名svn update 文件名

Example:

update <- 后面没有目录,默认将当前目录以及子目录下的所有文件都更新到最新版本svn update -r 200 test.cpp <- 将版本库中的文件 test.cpp 还原到修正版本(revision)200svn update test.php <- 更新与版本库同步。

Prompt for expiration conflict when submitting, need update to modify file first,
Then remove the SVN resolved and commit the commit again.

6. Delete Files
svn delete svn://路径(目录或文件的全路径) -m “删除备注信息文本”

The following actions are recommended:

svn delete 文件名 svn ci -m “删除备注信息文本”

Example:

delete svn://localhost/testapp/test.php -m “删除测试文件test.php”

The following actions are recommended:

svn delete test.php svn ci -m “删除测试文件test.php”
7. Locking/Unlock
svn lock -m “加锁备注信息文本“ [--force] 文件名 svn unlock 文件名

Example:

svn lock -m “锁信测试用test.php文件“ test.php svn unlock test.php
8. Compare differences
svn diff 文件名 svn diff -r 修正版本号m:修正版本号n 文件名

Example:

svn diff test.php200:201 test.php<- 对 修正版本号200 和 修正版本号201 比较差异
9. View file or directory status
svn st 目录路径/名svn status 目录路径/名<- 目录下的文件和子目录的状态,正常状态不显示              【?:不在svn的控制中;  M:内容被修改;C:发生冲突;              A:预定加入到版本库;K:被锁定】 svn  -v 目录路径/名svn status -v 目录路径/名<- 显示文件和子目录状态

"The first column remains the same, the second column shows the work version number,
The third and fourth columns show the last modified version number and the modified person "
Note: The SVN status, SVN diff, and SVN revert three commands can be executed without a network,
The reason is that SVN retains the original copy of the local version in the Local. SVN.

10. View Logs
svn log 文件名

Example:

log
11. View File Details
svn info 文件名

Example:

svn info test.php
12. SVN Help
svn help <- 全部功能选项svn help ci <- 具体功能的说明
13. View the list of files and directories under the repository
svn list svn://路径(目录或文件的全路径)svn ls svn://路径(目录或文件的全路径)

Example:

svn://localhost/testsvn://localhost/test <- 显示svn://localhost/test
14. Create a new directory under version control
svn mkdir 目录名svn mkdir -m "新增目录备注文本" http://目录全路径

Example:

mkdirmkdir -m"Making a new dir." svn://localhost/test/newdir

Note: After adding subdirectories, be sure to go back to the root directory update, or the file will be submitted in this directory would prompt "commit failed"

update

Note: If you create a new folder Newsubdir manually in the checkout directory,
After using the SVN mkdir newsubdir command, SVN will prompt:
SVN: Trying to replace with "svn add" or "svn add–non-recursive"?
SVN: Unable to create directory "Hello": File already exists
At this point, use the following command to resolve:
  

add--non-recursive newsubdir

When you enter this Newsubdir folder, you can see all the directories and files below it with ls-a:. SVN directory
Then use the SVN mkdir-m "Add Hello Function module file" Svn://localhost/test/newdir/newsubdir command,
SVN tip:
Svn:file already Exists:filesystem '/data/svnroot/test/db ', transaction ' 4541-1 ',
Path '/newdir/newsubdir '

15. Restore Local Modifications
svn revert [--recursive] 文件名

Note: The notebook command will not access the network and will release the conflicting condition. However, it does not restore the deleted directory.
Example:

svnrevertfoo.c<-丢弃对一个文件的修改svnrevert--recursive.<-恢复一整个目录的文件,.为当前目录
16. Update the work copy to another URL
svn switch http://目录全路径 本地目录全路径

Example:

switch http://localhost/test/456 . <- (原为123的分支)当前所在目录分支到localhost/test/456
17. Conflict resolution
svn resolved [本地目录全路径]

Example:

updateC foo.cUpdated to revision 31.

If you get a conflict during the update, your working copy will generate three new files:

$ lsfoo.cfoo.c.minefoo.c.r30foo.c.r31

When you have resolved the FOO.C conflict and are ready to submit, run SVN resolved and let your working copy know that you have done everything.
You can just delete the conflicting files and commit, but SVN resolved in addition to deleting the conflicting files, and also fixed some records in the work copy management area of the record data, so we recommend you use this command.

18, not checkout and view the content of the output specific file or URL
svn cat http://文件全路径

Example:

svn cat http://localhost/test/readme.txt
19. Create a new branch copy
copy branchA branchB  "make B branch"// 从branchA拷贝出一个新分支branchB
20. Merge content to branch merge
merge // 把对branchA的修改合并到分支branchB

Linux installation svn and configuration use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.