SVN学习 - 基础操作

34 篇文章 0 订阅

获取svn仓库

首先要知道svn地址,然后通过如下命令获取svn仓库:

svn checkout svn://svn_resp_url

或者简写:

svn co svn://svn_resp_url

SVN提交更新

SVN在提交更新的时候很简单:

svn commit -m "commit log content"

简写方法为:

svn ci -m "commit log content"

如果有新添加的文件需要先运行:

svn add file_path/file_name 

如果有新删除的文件需要:

svn rm file_path/filename

svn获取最新版本

如果长时间没动,需要获取服务器最新版本:

svn update

放弃本地修改

如果要放弃某个文件的本地修改(还没有commit):

svn revert foo.c //foo.c是文件路径+名字

如果要放弃所有修改:

svn revert --depth=infinity

已经commit

如果代码已经commit结束了,那么需要使用merge的方式来对代码进行回滚。
首先使用:

svn log //查看你要回滚到哪个版本

然后:

svn update //获取最新版本 得到版本号
svn merge -r 150:140 . //回滚代码从150回滚到140
svn commit -m "Rolled back to r140" //提交合并结果版本+1

这样就可以了。

打tag

如果当前已经开发一个版本结束,需要保存,这个时候不是记住版本号,而已打tag,这样就算作一个正式版本了。命令就是:

svn copy http://svn_server/xxx_repository/trunk http://svn_server/xxx_repository/tags/release-1.0 -m "1.0 released"

如果要删除某个tag:

svn rm http://svn_server/xxx_repository/tags/release-1.0

出现冲突

如果是同时多个人协作的话,或者自己在两个电脑上改了同一个地方的代码,是有可能出现冲突的(conflict),这个时候需要修改冲突。

在查看文件的时候可以看到:

<<<<<<< .mine

your code here

=======

other code here

>>>>>> .r1234

手工选择你想要的代码,然后使用:

svn reslove --accept working conflict_file.c

这里在accept后面有选项的,官方文档里是这样子写的:

working
Assuming that you've manually handled the conflict resolution, choose the version of the file as it currently stands in your working copy.

mine-full (mf)
Resolve conflicted files by preserving all local modifications and discarding all changes fetched from the server during the operation which caused the conflict.

theirs-full (tf)
Resolve conflicted files by discarding all local modifications and integrating all changes fetched from the server during the operation which caused the conflict.

mine-conflict (mc)
Resolve conflicted files by preferring local modifications over the changes fetched from the server in conflicting regions of each file's content.

theirs-conflict (tc)
Resolve conflicted files by preferring the changes fetched from the server over local modifications in conflicting regions of each file's content.

选择对应的选项就好了。
这个命令结束后,会自动删除冲突的临时文件conflict_file.c.mine conflict_file.c.r123这种文件。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值