准备
在SVNPort注册账号,我的用户名叫beast。新建项目,暂且命名为Start
1.下载项目代码到本地
cd ~
svn checkout https://vip2.svnspot.com/beast.Start/ --username=beast
2.提交代码初始化项目
在trunk目录下新建index.html,内容如下所示:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
然后提交代码
cd ~/beast.Start/trunk
svn status
svn add * --force
svn commit -m 'init'
3.新建分支开发
//在服务器上新建分支
svn copy -m '创建新分支' https://vip2.svnspot.com/beast.Start/trunk https://vip2.svnspot.com/beast.Start/branches/my_branch
//拷贝新分支代码到本地
cd ~/beast.Start/branches
svn checkout https://vip2.svnspot.com/beast.Start/branches/my_branch
//修改beast.Start/branches/my_branch/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<h1>Hello SVN!</h1>
</body>
</html>
4.提交修改并合并分支
//提交修改
svn status
svn add index.html --force
svn commit -m 'test'
//合并分支
cd ~/beast.Start/trunk
svn update
svn merge https://vip2.svnspot.com/beast.Start/branches/my_branch
svn status
svn add index.html --force
svn commit -m '合并分支'
//同理,把服务器上主分支merge到本地my_branch分支并提交
5.其他一些常用命令
svn info //显示当前目录版本信息
svn diff -r v1:v2 //比较v1和v2两个版本差异