转 八步学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.

原文地址:http://www.cnblogs.com/CloudTeng/archive/2011/12/08/2280344.html

时间: 2024-12-05 04:25:58

转 八步学SVN的相关文章

一步一步学ROP之linux_x64篇

一步一步学ROP之linux_x64篇 一.序 **ROP的全称为Return-oriented programming(返回导向编程),这是一种高级的内存攻击技术可以用来绕过现代操作系统的各种通用防御(比如内存不可执行和代码签名等).上次我们主要讨论了linux_x86的ROP攻击:<一步一步学ROP之linux_x86篇>,在这次的教程中我们会带来上一篇的补充以及linux_x64方面的ROP利用方法,欢迎大家继续学习. 另外文中涉及代码可在我的github下载:https://githu

一步一步学Silverlight :使用样式封装控件观感

概述 Silverlight 2 Beta 1版本发布了,无论从Runtime还是Tools都给我们带来了很多的惊喜,如支持框架语言Visual Basic, Visual C#, IronRuby, Ironpython,对JSON.Web Service.WCF以及Sockets的支持等一系列新的特性.<一步一步学Silverlight 2系列>文章带您快速进入Silverlight 2开发. 本文为系列文章第八篇,主要介绍在Silverlight中使用Style元素封装控件观感 Silv

八步拿下数据科学,攻克 “21世纪最性感的工作”

在数据科学(Data Science)领域,除了"什么是数据科学"这个问题以外,大家最感兴趣的问题就是"如何学习数据科学?"其实这个问题除了新手会问,有时候领域内的老手也有些迷惑. 数据科学家被誉为"2016年最佳工作",甚至是"21世纪最性感的工作",但学习起来真的并没有我们想象的那么轻松. 网络上可以找到大量关于学习数据科学的建议,但是如此大量的信息堆叠让可能还是让初学者感到无所适从.所以本文想要给出一个较为简单的学习方法

【DG】[三思笔记]一步一步学DataGuard

[DG][三思笔记]一步一步学DataGuard 它有无数个名字,有人叫它dg,有人叫它数据卫士,有人叫它data guard,在oracle的各项特性中它有着举足轻理的地位,它就是(掌声)......................Oracle Data Guard.而对于我而言,我一定要亲切的叫它:DG(注:主要是因为打着方便). 不少未实际接触过dg的初学者可能会下意识以为dg是一个备份恢复的工具.我要说的是,这种形容不完全错,dg拥有备份的功能,某些情况下它甚至可以与primary数据库

建站SEO的八步曲之谈

中介交易 SEO诊断淘宝客 站长团购 云主机 技术大厅 第一步:对自己为什么要做网站要有个清楚的认识,不要为了想赚钱而做网站,那样的话只会滋生急功近利的情绪,遇到一点挫折就灰心丧气.这真的很关键,现在为了做GG adsense或者其他广告联盟而做网站的应该不在少数吧.做什么事情只要你有兴趣那么你就成功了一半,所以你要抱着学习,慢慢进步的态度去做网站,脚踏实地从基本的HTML语言和DW学起,不要一上手就想着该怎么做SEO(搜索引擎优化),做任何事情打好基础是很关键的,生活/学习如此,做网站亦是!!

建站SEO八步曲 让你走出草根站长

中介交易 SEO诊断 淘宝客 云主机 技术大厅 建站SEO八步曲,让你走出草根站长 首先要感谢ADMIN5.COM,在这里我学到了很多东西,在这同时也想写点东西为ADMIN5和曾经帮助过我的站长朋友做点贡献,写的不好请见谅. 第一步:对自己为什么要做网站要有个清楚的认识,不要为了想赚钱而做网站,那样的话只会滋生急功近利的情绪,遇到一点挫折就灰心丧气.这真的很关键,现在为了做GG adsense或者其他广告联盟而做网站的应该不在少数吧.做什么事情只要你有兴趣那么你就成功了一半,所以你要抱着学习,慢

Seo做好这八步你就是第一

看我的标题大家就明白了,今天主要为大家分享的就是如何快速排名,快速seo,而我把从建站开始,一直到网站排名,经过我的长期总结,简单的阐述为八点,而通过这八点就能够快速获得排名,做好你的seo. Seo第一步:确定属于你行业的主要关键词.这其实看起来很基础的一步,却是很重要的一步,一般对于新手来说,可能做到这里的时候会比较马虎,而只有亲自做过站的人,清楚这一步的重要性在哪里.首页确定好你所要做的关键词,要分析整个行业的态势,这个词会为你带来流量吗,这个词带来的转化率好吗,做这个词有没有机会--等一

一步一步学EJB3.0(三):悟透会话Bean(下)

三.无状态会话Bean实例 在上一篇文章里,其实我们已经应用到了无状态会话Bean,那好,下面我们详细的来分析下上一篇文 章里给出的示例程序. 没有阅读过的朋友请点击这里阅读:<<一步一步学EJB 3.0(二):初探企业 EJB模块开发>> . 首先我们来看看接口的定义: 1 /** 2 * 远程接口 3 * @author Beniao 4 */ 5 @Remote 6 public interface HelloRemote { 7 void sayHello(String s

一步一步学NUnit(2)

前一章我们简单介绍了NUnit的入门示例<一步一步学NUnit(1)>,让大家对NUnit有个简单的认识. NUnit的使用是非常简单的,但是它在项目中使用时,有许多最佳实践.这章我们把上一章没有讲到的 NUnit的一些配置和特性介绍一下. 要想熟练地使用NUnit还是要在实践中使用和体会,单纯地学习知识点是没有用的. 好,不再废话了.继续上一章的内容. 在Visual Studio 2008 中打开上一章的示例,Calculator类有4个最简单的方法:加.减.乘.除. Calculator