svn-command

svn是一个开放源代码的版本库,是cvs的重写版和改进版
svn-command

原文链接

导出

下载项目
svn checkout 'url'
简写
svn co 'url'

添加指定文件或目录
svn add 'file'或'dir'

添加所有目录文件
svn add *

创建纳入版本目录
svn mkdir -m 'commit message' 'url/dir'

删除指定文件
svn delete 'file'
推荐组合
svn delete 'file name'
svn commit -m 'delete file name'

提交指定文件
svn commit -m 'commit message' 'file'

提交所有文件
svn commit -m 'commit message'
简写
svn ci -m    

查看文件或目录状态
svn status 'file'或'dir'
简写
svn st 'file'或'dir'
  • 正常状态不显示
  • ?:不在svn的控制中
  • M:内容被修改
  • C:发生冲突
  • A:预定加入到版本库
  • K:被锁定


    查看指定文件日志
    svn log ‘file’

    查看指定文件详细信息
    svn info ‘file’

    查看指定目录文件列表
    svn list ‘dir’

更新

更新指定文件
svn update 'file'

更新所有文件
svn update

锁定

加锁指定文件
svn lock -m 'commit message' 'file'  

解锁指定文件
svn unlock 'file' 

比较差异

比较指定文件差异
svn diff 'file'  

对指定文件的版本1和版本2比较差异
svn diff -r version1:version2 'file'  

分支

从分支A新建出一个分支B
svn copy branchA branchB -m 'commit message'    

解决冲突

svn resolved 

产生冲突是,会生成三个新的文件,svn resolved除了删除冲突文件,还修正了一些记录在工作拷贝管理区域的记录数据,推荐使用这个命令解决冲突。

帮助

svn help    
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Java中使用SVN上传文件,你可以使用SVNKit库。以下是一个简单的示例代码: 首先,确保你已经在项目中添加了SVNKit的依赖。例如,如果你使用Maven构建项目,可以在pom.xml文件中添加以下依赖: ```xml <dependency> <groupId>org.tmatesoft.svnkit</groupId> <artifactId>svnkit</artifactId> <version>1.10.3</version> </dependency> ``` 然后,你可以使用以下代码来执行文件上传操作: ```java import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions; import org.tmatesoft.svn.core.internal.wc.SVNFileUtil; import org.tmatesoft.svn.core.internal.wc2.compat.SvnCodec; import org.tmatesoft.svn.core.io.SVNRepository; import org.tmatesoft.svn.core.io.SVNRepositoryFactory; import org.tmatesoft.svn.core.wc.*; import java.io.File; public class SVNUploader { private static final String SVN_URL = "https://svn.example.com/svn/repository"; private static final String SVN_USERNAME = "your_username"; private static final String SVN_PASSWORD = "your_password"; public static void main(String[] args) { File fileToUpload = new File("path/to/your/file"); String destinationPath = "/path/in/repository"; SVNURL svnUrl = SVNURL.parseURIEncoded(SVN_URL); SVNRepository repository = SVNRepositoryFactory.create(svnUrl); ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(SVN_USERNAME, SVN_PASSWORD); repository.setAuthenticationManager(authManager); DefaultSVNOptions options = SVNWCUtil.createDefaultOptions(true); SVNClientManager clientManager = SVNClientManager.newInstance(options, authManager); SVNCommitClient commitClient = clientManager.getCommitClient(); try { SVNCommitInfo commitInfo = commitClient.doImport(fileToUpload, repository.getLocation().appendPath(destinationPath, false), "uploading file", null, true, false, SVNDepth.INFINITY); System.out.println("File uploaded successfully. Revision: " + commitInfo.getNewRevision()); } catch (SVNException e) { System.err.println("Error uploading file: " + e.getMessage()); } } } ``` 请注意,你需要将示例代码中的SVN_URL、SVN_USERNAME和SVN_PASSWORD替换为你自己的SVN服务器的URL、用户名和密码。 这段代码使用SVNKit库来连接到SVN服务器,并使用提供的用户名和密码进行身份验证。然后,它使用SVNCommitClient的doImport方法将文件上传到指定的路径。上传完成后,将打印出新的版本号。 请记住,在运行代码之前,确保你的项目已经添加了SVNKit库的正确依赖,并且替换了示例代码中的SVN_URL、SVN_USERNAME和SVN_PASSWORD。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值