SVN command under Linux Introduction

1. Place the server files checked out to the local

  • Check out a file folder
svn checkout svn://192.168.16.68/demo/trunk /home/tom/works/demo/
  • Check out the entire contents of the folder
cd /home/tom/works/demo
svn checkout svn://192.168.16.68/demo/trunk/ .
  • Check out a version of the file
svn checkout -r 88 svn://192.168.16.68/demo/trunk /home/tom/works/demo/

2. Add a new file

svn add new.txt #需要提供修改后才能改变服务器里的内容

3. Submit modified

svn commit -m "添加了新文件" new.txt

4. Update version

  • All Updates
svn update
  • Update file to a version
svn update -r 88 test.c

5. Delete Files

svn delete test.c -m "删除测试文件" #需要提供修改后才能改变服务器里的内容

6. View Log

svn log new.txt

7. View file status

  • Display file status
svn status new.txt
#不显示:正常状态
#?:不受版本控制
#M:内容被修改
#C:发生冲突
#A:预定加入到版本库
#D:预订从版本库中删除
#K:被锁定
  • Modify status display
svn status -v path
#工作版本号 最后一次修改的版本号 最后一次修改的用户 文件名
#9        			9 			jerry        .
#9        			4 			wfc          a.h
#9        			4 			wfc          array
#9        			4 			wfc          array/array_hosts_for.sh
#9        			4 			wfc          array/array_hosts_while.sh
#9        			4 			wfc          array/count_shells.sh

8. view the file information

svn info new.txt

9. Compare the difference

  • Comparing the current content and the latest version
svn diff new.txt
  • Comparing the current content and a version
svn diff -r 88 new.txt
  • Compare any two versions
svn diff -r 88:99 new.txt

10. The lock / unlock

svn lock new.txt -m "加锁"
svn unlock new.txt

11. version merger

The two different versions diff, the result of diff then applied to the document.

  • Forward merger
$ svn merge -r old:new new.txt #old:以前的版本;new:新版本
  • Reverse merger
    if submitted after the code found need to roll back to an older version, you can use the merge to complete the operation.
$ svn merge -r new:old new.txt #old:要回滚到的版本;new:新版本

12. resolve conflicts

In use svn update occurs, submitted, during merger conflict, which is similar to the solution, the following update to an example, as shown below:
Here Insert Picture Description
can modify the file by editing the input e, to resolve the conflict. ** If there is "not set SVN_EDITOR, VISUAL or EDITOR environment variables" ** problem, you need to set environment variables:

$ vim ~/.bash_profile #打开bash配置文件,在文件最后添加 export SVN_EDITOR=vim
$ source ~/.bash_profile #使新配置生效

After entering e, open the editor displays the following:
Here Insert Picture Description
modify the file according to the actual needs and solve conflicting problems, and then save and exit. Select (r) exit to update to the latest version, and then continue to modify their final submission.
Here Insert Picture Description
For other situations of conflict, post-conflict revised and need to re-mark the file as resolved the conflict, as follows:

$ svn resolved new.txt

13. restore local modifications

$ svn revert new.txt

14. Add a folder

  • Added directly in the repository
$ svn mkdir svn://127.0.0.1/demo/trunk/newDir -m "添加新文件夹newDir"
  • Add in the working directory, and then commit the changes
$ svn mkdir newDir
$ svn commit -m "添加新文件夹newDir"

15. Create branch

$ svn copy svn://127.0.0.1/demo/trunk svn://127.0.0.1/demo/branches/branch1 -m "创建第一分支"
#如果svn://127.0.0.1/demo/branches/branch1文件夹已经存在,则拷贝trunk文件夹到branch1文件夹下

16. Merge branch to the trunk

#cd到主干的本地工作目录
$ svn update #需要更新到最新版本,否则会无法合并
$ svn merge svn://127.0.0.1/demo/branches/branch1 #合并分支中的内容到本目录,如果有冲突虚解决冲突

17. A switching code repository URL

$ svn swtich newURL

18. The display of files and directories in the repository directory

$ svn list svn://127.0.0.1/demo/trunk
Published 15 original articles · won praise 1 · views 4612

Guess you like

Origin blog.csdn.net/loveangel1/article/details/104264718