所以我环顾四周,没有看到我的具体例子。希望这是有道理的 -
我正在寻找一种方法来删除文件中但在一次提交中发生的更改,并保留之后发生的更改(直到HEAD)。
例如
第一次提交foo.js
var x = "hello";
console.log(x);
第二次提交foo.js
var x = "hello";
var y = "blah";
console.log(x);
console.log(y);
3rd commit foo.js
var x = "hello";
var y = "blah";
console.log(x);
console.log(y);
var z = "world";
第4次提交(HEAD)foo.js
var x = "hello";
var y = "blah";
console.log(x);
console.log(y);
var z = "world";
console.log(x + " " + z);
现在我想恢复第二次提交,使文件看起来像
var x = "hello";
console.log(x);
var z = "world";
console.log(x + " " + z);
对我有任何提示?我希望用revert而不是手动(删除文件中的行并提交)
我尝试过(How do I revert an SVN commit?)
//svn merge -c -[R] .
svn merge -c -2 foo.js
并且它在提交2之后摆脱了所有更改
答案 0 :(得分:1)
使用您的数据在我的仓库中进行样本测试
>svn log
------------------------------------------------------------------------
r5 | Badger | 2015-02-01 12:03:39 +0500 (Вс, 01 фев 2015) | 1 line
Change 3
------------------------------------------------------------------------
r4 | Badger | 2015-02-01 12:03:00 +0500 (Вс, 01 фев 2015) | 1 line
Change 2
------------------------------------------------------------------------
r3 | Badger | 2015-02-01 12:02:02 +0500 (Вс, 01 фев 2015) | 1 line
Change 1
------------------------------------------------------------------------
r2 | Badger | 2015-02-01 12:01:22 +0500 (Вс, 01 фев 2015) | 1 line
Initial state
------------------------------------------------------------------------
r1 | Badger | 2015-02-01 12:00:01 +0500 (Вс, 01 фев 2015) | 1 line
Imported folder structure
------------------------------------------------------------------------
您的更改位于我的r3中,如您所见
>svn diff -c 3
Index: foo.js
===================================================================
--- foo.js (revision 2)
+++ foo.js (revision 3)
@@ -1,2 +1,4 @@
var x = "hello";
+var y = "blah";
console.log(x);
+console.log(y);
使用HEAD-state
>svn cat foo.js
var x = "hello";
var y = "blah";
console.log(x);
console.log(y);
var z = "world";
console.log(x + " " + z);
我无法在没有冲突的情况下反向合并(diff是上下文感知的)(我的repo是单文件,因此我可以使用.
)
>svn merge -c -3 .
--- Reverse-merging r3 into '.':
C foo.js
--- Recording mergeinfo for reverse merge of r3 into '.':
G .
Conflict discovered in file 'foo.js'.
Select: (p) postpone, (df) show diff, (e) edit file, (m) merge,
(mc) my side of conflict, (tc) their side of conflict,
(s) show all options
对于此类冲突,最佳策略可能使用任何预先配置的GUI工具进行合并
或就地编辑文件(你知道,你想得到哪个结果)