转 八步学SVN

简介:

 This week I was attending a CI training course about svn. Here I'd like to share what I have learnt. As I am an absolutely green bird to svn, this post only covers those most common usages.

(1) Create a repository

      Given that we already have a project with a directory structure as below:

          my-project

           |____branches

           |____tags

           |____trunk

           | |____etc

           | | |____conf.txt

           | |____source.txt 

     Now we want to create a svn repository to accomodate this project, first we need to initialize an empty repository:

svnadmin create path/to/svn-repository

 

(2) Run SVN server

svnserve -d -r path/to/svn-repository


     The "-d" option tells svn server to run as a deamon, and the "-r" option tells the server the location of our repository, now we are able to access our repository using URL: svn://localhost. In order to allow any anonymous user to have both read and write permission(this may not be a good practice, we do so just for convenience), we can modify the configuration file named svnserve.conf located under the repository's conf subfolder, comment in these two lines:

anon-access = write
auth-access = write

     Now we are able to read and write to the repository without providing a user account.


(3) Import a project 

     Once the repository has been created, the next step is to import our project into the repository:   

svn import path/to/my-project svn://localhost


     An svn repository for our project has been created, you may take a look at our newly imported project in the repository with:

svn list svn://localhost
     branches/
     tags/
     trunk/

 

     As we can see, the directory structure in the repository is exactly the same as the original project.

 

(3) Checkout the code

     We don't have to pay much attention to our original project any more as svn repository already contains the whole project, then if someone wants to make a working copy, she/he can make a checkout:       

svn checkout svn://localhost/trunk working-trunk


     The command above checks out the trunk folder to working-trunk, other folders can also be checked out using the correspond subfolder name, or the whole project can be checked out with no folder names. 

 

(4) Make some change

     Now switch to working-trunk and make your own change, you can modify a file directly, or add a new file using "svn add filename", delete a file using "svn delete filename", and rename a file using "svn rename old-filename new file-name".

 

(5) Checkin the changed code

     Once we are confident enough to publish our change to the repository, we can check in our code. But before we check in our code, we need to pull the latest code from repository given that others may have checked in their code, we can use the command below to update our own working copy:       

svn update


     If we are lucky as there's no conflict between our own change and those pulled from the repository, we can check in our code directly:     

svn commit -m "description of my change"


(6) Manage merging

     In step (5), we were praying our own change doesn't overlap with the changes made by others, but there are times our change do overlap with others' code and conflict occurs when someone modified the same lines of code as ourselves do, under such circumstances we need to merge the conflict manually. If we try to update our own working copy  when there is conflict, we will get the following information:

          Conflict discovered in 'source.txt'.

          Select: (p) postpone, (df) diff-full, (e) edit,

                  (mc) mine-conflict, (tc) theirs-conflict,

                  (s) show all options:

     There are sevral options to choose, with "postpone" to skip editing the conflict for the time being, "edit" to nevigate us to edit the conflict right now etc.. If we choose "(p)postpone", the conflict will remain there for later resovle, and our conflicting file(source.txt) will be marked in its content as having conflict:

           ............

          <<<<<<< .mine

          this is modified by me

          =======

          this is modified by another person

          >>>>>>> .r6

          ............ 

     The content between "<<<<<<<<" and "=======" shows our own change while the content between "======"  and ">>>>>>" shows changes make by others. Now if we want to keep both changes, what we can do is to edit the conficting file as below:

          .............

          this is modified by me

          this is modified by another person

          .............

     and then tell svn the file has been merged by using:              

svn resolve --accept=working source.txt


     next, don't forget to commit the merge:       

svn commit -m "merge source.txt"


(7) Branching

     svn uses "svn copy" to create branches, chances are that we are at some stage of trunk development and we want to introduce a new feature without influencing the trunk, making a new branch for that feature is a good choice. To create a branch in svn:       

svn copy svn://localhost/trunk svn://localhost/branches/new-feature -m "create a new branch named new-feature"


     Now we can check out the new branch and implement new feature in it:      

svn checkout svn://localhost/branches/new-feature

 

(8) Tagging

     Tagging in svn is implemented in the same way as branching, yet tagging differs from branching is that tagging usually serves as a purpose to create a stable version from trunk.



目录
相关文章
|
25天前
|
弹性计算
阿里云免费服务器在哪申请?有什么条件吗?免费使用多长时间?
阿里云免费服务器通过“免费试用中心”申请:https://t.aliyun.com/U/88JkrU 仅限新用户:需实名认证、无欠费、未购/试用过ECS。个人享300元/3个月,企业660元/3个月,含20–200GB免费流量,支持多地域与多种实例规格。到期不自动释放,须手动处理避免计费。
|
3月前
|
存储 关系型数据库 MySQL
对账差了三毛钱,查完我把全部金额字段从DOUBLE改成了DECIMAL
一次财务对账差三毛钱的排查,牵出金额字段用浮点数的老坑。从IEEE 754为什么存不准0.1讲起,用同一批金额把FLOAT、DOUBLE、DECIMAL三种类型实测对比,再给出金额字段的选型、聚合与改表做法,附避坑清单。
|
4月前
|
人工智能 测试技术 Shell
OpenCode开源AI编程助手实操:替代Claude Code对接百炼完整教程
在AI编程Agent快速普及的当下,很多开发者习惯使用闭源编程代理工具完成项目重构、bug修复、新功能开发,但闭源工具存在诸多现实痛点。一方面工具完全绑定自家模型,无法自由切换推理后端;另一方面账号风控策略严苛,容易出现账号受限、调用中断的情况,企业内部开发还会面临代码数据外送带来的数据安全风险。OpenCode作为一款开源AI编程代理框架,被很多开发者视作Claude Code的优质替代方案,它不绑定任何大模型厂商,支持对接云端大模型服务,也可以接入本地私有化部署模型,同时完整复刻终端Agent的文件读写、命令执行、项目分析等核心能力,搭配百炼平台的各类代码大模型,就可以搭建一套完全自主可控
599 1
|
3月前
|
人工智能 运维 Rust
Codex终端AI编程助手实操全解:部署安装、百炼Coding Plan与Token Plan接入完整教程
现代软件工程迭代节奏持续加快,传统IDE普遍存在体积臃肿、启动缓慢、操作链路繁琐等问题。各类图形界面AI编码插件高度依赖可视化操作环境,无法适配纯终端远程服务器开发、轻量化脚本快速迭代、服务器运维编码等业务场景。市面上大量终端编程工具能力较为单薄,大多仅提供基础代码片段补全,缺少项目全局理解、多步骤任务自治、批量工程重构、安全沙箱防护等高阶能力;同时直接使用海外模型服务,还会遭遇网络链路不稳定、计费不可控、难以适配国内合规开发体系等现实阻碍。
455 0
|
关系型数据库 MySQL Shell
三、Docker常用命令
把 Docker 玩转,就像一个建筑师,需要掌握两套核心工具:一套用来管理你的“图纸”(镜像),另一套用来管理你用图纸盖好的“房子”(容器)。
932 3
|
12月前
|
弹性计算 固态存储 大数据
阿里云服务器新购、续费、升级优惠价格表:年/月/小时收费明细
目前阿里云服务器新购、续费、升级多少钱一年?最新阿里云服务器多少钱一年?上云就上阿里云 ,很多用户以为阿里云服务器价格比较贵,事实上,阿里云服务器的价格多次降价,云服务器相比其他云厂商有很大的优惠,整理今年本月最新的云服务器租用价格表,包括轻量应用服务器、云服务器ECS和GPU服务器。目前最新阿里云服务器租用费用价格表,轻量2核2G轻量服务器一年68元,折合5.6元1个月,新老用户同享99元一年服务器,2核4G5M服务器ECS优惠价199元一年(企业专享),2核4G4M轻量服务器298元一年,4核8G服务器955元一年,4核16G10M服务器70元1个月、210元3个月,8核32G服务器160
|
监控 供应链 数据可视化
深入聊聊MES、ERP、SCM、WMS、APS、SCADA、PLM、QMS的区别与联系
在企业信息化数字化进程中,ERP、MES、SCM、WMS等系统发挥着关键作用。本文详解各系统功能、应用场景及相互关系,帮助企业构建高效协同的数字化管理体系。
|
存储 人工智能 自然语言处理
基于MCP的桥梁设计规范智能解析与校审系统构建实践
本文探讨了在桥梁设计领域应用AI技术的实践与思考,针对传统设计中规范查阅效率低、理解偏差大等问题,提出基于MCP协议构建智能解析与校审系统。系统通过PDF解析、知识图谱构建及自然语言处理等技术,实现规范条文的结构化存储和智能化应用,大幅提升设计效率与准确性。开发过程中克服了多模态文档解析、专业术语理解等挑战,并通过迭代优化持续改进性能。未来该系统有望扩展至更多工程领域,推动设计流程智能化升级。
641 8
|
传感器 数据采集 IDE
Sensor Shield V5.0
Sensor Shield V5.0是一款Arduino扩展板,它提供了多个数字和模拟信号输入输出接口,可以方便地连接和控制各种传感器和执行器。
2603 1