svn命令之恢复误删的文件

本文介绍如何通过Subversion (SVN) 的命令行工具恢复误删的文件。通过使用merge命令并指定版本范围,可以找回被误删的index.c文件,并将其重新提交到版本库。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

如何恢复svn上误删的文件

项目目录、文件内容及历史记录如下所示


我们模拟进行了几次增删动作,最后删除index.c文件



现在,我们用命令行将工程检出

[root@localhost project]# svn co https://10.200.1.201/HSM/branches/test
A    test/src
Checked out revision 48243.

进行src目录下,cd test/src

执行merge命令

[root@localhost src]# svn merge -r HEAD:48236 https://10.200.1.201/HSM/branches/test/src .
--- Reverse-merging r48243 through r48237 into '.':
A    index.c
[root@localhost src]# 
查看svn状态,发现有一个文件index.c添加

[root@localhost src]# svn st
A  +    index.c
将文件提交到svn上

[root@localhost src]# svn ci -m "resovle index.c"
Adding         src/index.c

Committed revision 48244.

查看index.c的历史记录,发现找回来了

[root@localhost src]# svn log index.c -v
------------------------------------------------------------------------
r48244 | zqteng | 2016-07-05 21:21:05 +0800 (Tue, 05 Jul 2016) | 1 line
Changed paths:
   A /branches/test/src/index.c (from /branches/test/src/index.c:48236)

resovle index.c
------------------------------------------------------------------------
r48236 | zqteng | 2016-07-05 20:13:48 +0800 (Tue, 05 Jul 2016) | 1 line
Changed paths:
   M /branches/test/src/index.c

test5
------------------------------------------------------------------------
r48235 | zqteng | 2016-07-05 20:13:39 +0800 (Tue, 05 Jul 2016) | 1 line
Changed paths:
   M /branches/test/src/index.c

test4
------------------------------------------------------------------------
r48234 | zqteng | 2016-07-05 20:13:31 +0800 (Tue, 05 Jul 2016) | 1 line
Changed paths:
   M /branches/test/src/index.c

test3
------------------------------------------------------------------------
r48233 | zqteng | 2016-07-05 20:13:24 +0800 (Tue, 05 Jul 2016) | 1 line
Changed paths:
   M /branches/test/src/index.c

test2
------------------------------------------------------------------------
r48232 | zqteng | 2016-07-05 20:13:16 +0800 (Tue, 05 Jul 2016) | 1 line
Changed paths:
   A /branches/test/src/index.c

test1
------------------------------------------------------------------------
以下是eclipse中查看index.c文件的截图,以及文件内容








评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值