1.更改配置(不懂的话就直接跳过吧)
bogon:~ chenshuangchou$ open ~/.subversion/config
启动配置文件,然后在配置文件中选择要忽略的文件类型
找到 global-ignores 一行,去掉注释,编辑成
global-ignores = build *~.nib *.so *.pbxuser *.mode *.perspective*
# global-ignores = *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo
找到 enable-auto-props = yes 把注释去掉,在[auto-props] Section声明以下文本文件
*.mode* = svn:mime-type=text/X-xcode
*.pbxuser = svn:mime-type=text/X-xcode
*.perspective* = svn:mime-type=text/X-xcode
*.pbxproj = svn:mime-type=text/X-xcode
2.import命令
首先将本地代码import到版本库
bogon:~ chenshuangchou$ svn import /Users/chenshuangchou/Desktop/BuickIOS/Buickhousekeeper
3.checkout命令
然后从版本库checkout出来,这个目录就相当于被激活,内部跟服务器地址关联。
bogon:~ chenshuangchou$svn checkout https://192.168.21.248:8443/svn/BuickIOS/ /Users/chenshuangchou/Desktop/BuickIOS
4.add命令
当有新增的文件时用add指令,增加到版本库,然后提交
svn add /Users/chenshuangchou/Desktop/BuickIOS/Buickhousekeeper/ViewControllers/CarViewController/FuelManageViewController
执行这条指令的前提是/Users/chenshuangchou/Desktop/BuickIOS/是从服务器checkout下来的目录,也就是is a working copy
新增成功的话会有
A
5.commit命令
提交内容到版本库
bogon:~ chenshuangchou$ svn commit -m "添加了一个油耗柱状图" /Users/chenshuangchou/Desktop/BuickIOS/Buickhousekeeper/ViewControllers/CarViewController/FuelManageViewController
提交到版本库成功的话,
Adding
Transmitting file data .
Committed revision 3.
6.update命令
更新版本库到本地,更新指定目录,svn update如果后面没有目录,默认将当前目录以及子目录下的所有文件都更新到最新版本。
bogon:~ chenshuangchou$ svn update /Users/chenshuangchou/Desktop/BuickIOS1
更新成功
Updating 'Desktop/BuickIOS1':
A
Updated to revision 3.
回退到版本2:
bogon:~ chenshuangchou$ svn update -r 2 Desktop/BuickIOS1/
回退成功的话
Updating 'Desktop/BuickIOS1':
D
Updated to revision 2.
冲突
(更新,于版本库同步。如果在提交的时候提示过期的话,是因为冲突,需要先update,修改文件 ,然后清除svn resolved ,最后再提交commit)
在提交时发生版本冲突会怎么样
bogon:~ chenshuangchou$ svn commit -m "在delegate中加入了一句话" /Users/chenshuangchou/Desktop/BuickIOS/
Sending
Sending
Sending
Transmitting file data ...
Committed revision 4.
bogon:~ chenshuangchou$ svn commit -m "在delegate中加入了一句不同的话" /Users/chenshuangchou/Desktop/BuickIOS1/
Sending
svn: E160042: Commit failed (details follow):
svn: E160042: File or directory '.git/index' is out of date; try updating
svn: E160024: resource out of date; try updating
out
遇到这种情况,应该先从服务器update一下,然后再提交
bogon:~ chenshuangchou$ svn update
Updating 'Desktop/BuickIOS1':
Conflict discovered in '/Users/chenshuangchou/Desktop/BuickIOS1/.git/index'.
Select: (p) postpone,
在这里会有一个选择,选择(s)会显示所有选项的所有注释,如下
(s)
(e)
(df) diff-full
(r)
(dc) display-conflict - show all conflicts (ignoring merged version)
(mc) mine-conflict
(tc) theirs-conflict
(p) postpone
(mf) mine-full
(tf) theirs-full
选择一个之后会继续显示冲突点,直到完。而每一个点都会询问怎么处理。
G
Conflict discovered in '/Users/chenshuangchou/Desktop/BuickIOS1/Buickhousekeeper/AppDelegate.h'.
Select: (p) postpone, (df) diff-full, (e) edit,
G
Updated to revision 4.
选择tf之后,冲突点会被服务器上的代码覆盖,自己本地代码会永久不见。最好先选择postpone,确定之后再修改。
关于冲突,可以参考:http://www.logicaltrinkets.com/wordpress/?p=178
7.status命令
查看文件或者目录状态
svn status path (目录下的文件和子目录的状态,正常状态不显示)
?:不在svn的控制中;M:内容被修改;C:发生冲突;A:预定加入到版本库;K:被锁定
svn status -v path 显示所有文件的修改信息,在查看状态的同时,显示本地当前版本号,最后一次修改的版本号和修改人,分别在前
bogon:~ chenshuangchou$ svn status
M
?
?
?
?
M
?
?
?
?
M
M
8.delete命令
svn delete path -m " delete test fle "
删除一个空白的文件夹:
bogon:~ chenshuangchou$ svn delete /Users/chenshuangchou/Desktop/BuickIOS/branches
D
显示删除成功
9.log命令
查看版本记录,也叫日志
bogon:~ chenshuangchou$ svn log /Users/chenshuangchou/Desktop/BuickIOS
------------------------------------------------------------------------
r3 | chensc | 2013-10-31 11:34:03 +0800 (四, 31 10 2013) | 1 line
添加了一个油耗柱状图
------------------------------------------------------------------------
r2 | chensc | 2013-10-28 12:00:36 +0800 (一, 28 10 2013) | 1 line
initial import
------------------------------------------------------------------------
r1 | VisualSVN Server | 2013-06-28 17:40:29 +0800 (五, 28
Initial structure.
只有两个版本记录,说明第二个版本和第三个版本未添加版本说明,也就是在执行指令时未添加-m
10.diff命令
svn diff path(将修改的文件与基础版本比较)
在上传版本时,可能有自己版本与服务器版本不一致,需要查看具体代码,这个命令就可以做到
svn diff -r m:n path
对版本m和版本n比较差异
在追溯版本问题时,这个命令也十分有用
bogon:~ chenshuangchou$ svn diff /Users/chenshuangchou/Desktop/BuickIOS1
--- /Users/chenshuangchou/Desktop/BuickIOS1/Buickhousekeeper/AppDelegate.h (revision 4)
+++ /Users/chenshuangchou/Desktop/BuickIOS1/Buickhousekeeper/AppDelegate.h (working copy)
@@ -6,6 +6,7 @@
+
@@ -15,7 +16,7 @@
-@end
+@end
11.merge命令
将两个版本之间的差异合并到当前文件
bogon:BuickIOS chenshuangchou$ svn merge -r 4:5 /Users/chenshuangchou/Desktop/BuickIOS/Buickhousekeeper/AppDelegate.h
一般会发生冲突,处理冲突
— /Users/chenshuangchou/Desktop/BuickIOS/Buickhousekeeper/svn-1FUb4k 四 10 31 15:36:15 2013
+++ /Users/chenshuangchou/Desktop/BuickIOS/.svn/tmp/AppDelegate.h.tmp 四 10 31 15:36:16 2013
@@ -4,8 +4,13 @@
-//测试的很好
+<<<<<<< .working
+//测试一下
+=======
+//验证版本差异合并
+>>>>>>> .merge-right.r5
12.ls命令
版本库下的文件和目录列表
svn list path显示path目录下的所有属于版本库的文件和目录
bogon:BuickIOS chenshuangchou$ svn ls https://192.168.21.248:8443/svn/BuickIOS/
.git/
Buickhousekeeper/
Buickhousekeeper.xcodeproj/
DevOneSDK.framework/
branches/
tags/
trunk/
13.log命令
查看文件详细信息
bogon:~ chenshuangchou$ svn info /Users/chenshuangchou/Desktop/BuickIOS/Buickhousekeeper/AppDelegate.h
Path: Desktop/BuickIOS/Buickhousekeeper/AppDelegate.h
Name: AppDelegate.h
Working Copy Root Path: /Users/chenshuangchou/Desktop/BuickIOS
URL: https://chensc@192.168.21.248:8443/svn/BuickIOS/Buickhousekeeper/AppDelegate.h
Repository Root: https://chensc@192.168.21.248:8443/svn/BuickIOS
Repository UUID: 9a03820f-37b7-b94a-a594-74c58a350bc6
Revision: 4
Node Kind: file
Schedule: normal
Last Changed Author: chensc
Last Changed Rev: 4
Last Changed Date: 2013-10-31 14:04:51 +0800 (四, 31 10 2013)
Text Last Updated: 2013-10-31 14:02:51 +0800 (四, 31 10 2013)
Checksum: 83d8a08d317af33501b65051
14.其它命令
svn mkdir : 创建纳入版本控制下的新目录。
用法: 1、mkdir PATH...
2、mkdir URL...
svn revert : 恢复原始未改变的工作副本文件 (恢复大部份的本地修改)。revert:
用法: revert PATH...
注意: 本子命令不会存取网络,并且会解除冲突的状况。但是它不会恢复
被删除的目录
svn switch (sw): 更新工作副本至不同的URL。
用法: 1、switch URL [PATH]
svn resolved: 移除工作副本的目录或文件的“冲突”状态。
用法: resolved PATH...
注意: 本子命令不会依语法来解决冲突或是移除冲突标记;它只是移除冲突的
相关文件,然后让 PATH 可以再次提交。
svn cat 输出指定文件或URL的内容。
svn cat 目标[@版本]...如果指定了版本,将从指定的版本开始查找。
svn cat -r PREV filename > filename (PREV 是上一版本,也可以写具体版本号,这样输出结果是可以提交的)