如何在不删除其后续修订的情况下切换回文件的先前版本?

时间:2022-09-11 16:48:32

I have 4 versions of file A.txt in my subversion repository, say: A.txt.r1, A.txt.r2, A.txt.r3 and A.txt.r4. My working copy of the file is r4 and I want to switch back to r2. I don't want to use "svn update -r 2 A.txt" because this will delete all the revisions after r2, namely r3 and r4.

我的subversion存储库中有4个版本的文件A.txt,例如:A.txt.r1,A.txt.r2,A.txt.r3和A.txt.r4。我的文件工作副本是r4,我想切换回r2。我不想使用“svn update -r 2 A.txt”,因为这将删除r2之后的所有修订版,即r3和r4。

So is there any way that I update my working copy to r2 and still having the option to switch to r3 and r4 later? Put it another way, I want to still be able to see all 4 revisions by using "svn log A.txt" after doing the update.

那么有什么方法可以将我的工作副本更新到r2并且仍然可以选择稍后切换到r3和r4吗?换句话说,我希望仍然能够在执行更新后使用“svn log A.txt”查看所有4个修订版。

7 个解决方案

#1


3  

I don't have a lot of experience with Subversion so please excuse me if this method doesn't work in this environment.

我没有很多Subversion的经验所以请原谅我这种方法在这种环境下不起作用。

In this situation I follow these steps:

在这种情况下,我遵循以下步骤:

  1. Check out the file in question ready for editing as r4
  2. 查看有问题的文件,准备编辑为r4

  3. Overwrite your local copy of the file with the revision you require, in this case r2
  4. 使用您需要的修订覆盖文件的本地副本,在本例中为r2

  5. Check in / commit this "new" revision of the file as r5 with an appropriate comment
  6. 将该文件的“新”修订版本作为r5签入/提交,并附上相应的注释

This way when you go through your file history you will see something like:

这样,当您浏览文件历史记录时,您会看到以下内容:

  • r1
  • r2
  • r3
  • r4
  • r5 (comment: "reverted to r2 content")
  • r5(评论:“恢复到r2内容”)

#2


26  

To make a new revision of A.txt that is equal to revision 2:

要使A.txt的新修订版等于修订版2:

svn up -r HEAD
svn merge -r HEAD:2 A.txt
svn commit

Also see the description in Undoing changes.

另请参阅撤消更改中的说明。

#3


10  

The command svn up -r 4 only updates your local copy to revision 4.

命令svn up -r 4仅将本地副本更新为版本4。

The server still has all versions 1 through to whatever.

服务器仍然具有所有版本1到任何版本。

What you want to do, is create a new revision, revision number 5, which is identical to revision number 2.

您要做的是创建一个新版本,修订号为5,与修订号2相同。

cd /repo 
svn up -r 2 
cp /repo/file /tmp/file_2 
svn up -r 4 
cp /tmp/file_2 /repo/file 
svn commit -m "Making 5 from 2" 

If you ever change your mind and want 4 back, you can do so by creating revision 6 from revision 4.

如果您改变主意并希望4回来,您可以通过从修订版4创建修订版6来实现。

cd /repo 
svn up -r 4
cp /repo/file /tmp/file_4
svn up -r 5 
cp /tmp/file_4 /repo/file 
svn commit -m "Making 6 from 4" 

Happy hacking.

( there is of course a way to do the above in only 2 commands i believe, but its been a while since I did it and it can be a little confusing )

(当然有一种方法可以在我认为的2个命令中完成上述操作,但是自从我做了它已经有一段时间了,它可能有点令人困惑)

#4


3  

svn update -r 2 A.txt

This command will not delete any versions in the repository. It will set your working copy of A.txt to be revision 2. You can see this by doing

此命令不会删除存储库中的任何版本。它会将A.txt的工作副本设置为修订版2.您可以通过执行此操作来查看

> svn status -u A.txt
  *     2   A.txt

The output of this command show that you are viewing version 2, and that there are updates (that's the *).

此命令的输出显示您正在查看版本2,并且存在更新(即*)。

After doing this update, you will still be able to do "svn log" and see all the revisions.

执行此更新后,您仍然可以执行“svn log”并查看所有修订。

Performing "svn update A.txt" will return you to the latest version (in your case, r4).

执行“svn update A.txt”将返回最新版本(在您的情况下,r4)。

#5


2  

updating to an older rev will not delete your newer revs.

更新到较旧的转速不会删除您的较新转速。

so you could do svn up -r2 file, then svn up -r4 file.

所以你可以做svn up -r2文件,然后svn up -r4文件。

also, you wouldn't be able to commit the r2 file this way, because you'd have to update before committing, and you'd end up with r4 again.

另外,你不能以这种方式提交r2文件,因为你必须在提交前更新,你最终会再次使用r4。

#6


2  

"I don't want to use "svn update -r 2 A.txt" because this will delete all the revisions after r2, namely r3 and r4."

“我不想使用”svn update -r 2 A.txt“,因为这将删除r2之后的所有修订,即r3和r4。”

Uh... it won't, actually. Try it: do a regular svn update after the -r 2 one and you'll see the working copy updated back to r4.

呃......实际上它不会。试试看:在-r 2之后进行常规的svn更新,你会看到工作副本更新回到r4。

#7


1  

Update won't delete any revisions on the server. The only changes it makes are to your local working copy:

更新不会删除服务器上的任何修订。它所做的唯一更改是您的本地工作副本:

SVN Update Command

SVN更新命令

"brings changes from the repository into your working copy"

“将存储库中的更改带入您的工作副本”

"synchronizes the working copy to the revision given by the --revision switch"

“将工作副本同步到--revision开关给出的修订”

#1


3  

I don't have a lot of experience with Subversion so please excuse me if this method doesn't work in this environment.

我没有很多Subversion的经验所以请原谅我这种方法在这种环境下不起作用。

In this situation I follow these steps:

在这种情况下,我遵循以下步骤:

  1. Check out the file in question ready for editing as r4
  2. 查看有问题的文件,准备编辑为r4

  3. Overwrite your local copy of the file with the revision you require, in this case r2
  4. 使用您需要的修订覆盖文件的本地副本,在本例中为r2

  5. Check in / commit this "new" revision of the file as r5 with an appropriate comment
  6. 将该文件的“新”修订版本作为r5签入/提交,并附上相应的注释

This way when you go through your file history you will see something like:

这样,当您浏览文件历史记录时,您会看到以下内容:

  • r1
  • r2
  • r3
  • r4
  • r5 (comment: "reverted to r2 content")
  • r5(评论:“恢复到r2内容”)

#2


26  

To make a new revision of A.txt that is equal to revision 2:

要使A.txt的新修订版等于修订版2:

svn up -r HEAD
svn merge -r HEAD:2 A.txt
svn commit

Also see the description in Undoing changes.

另请参阅撤消更改中的说明。

#3


10  

The command svn up -r 4 only updates your local copy to revision 4.

命令svn up -r 4仅将本地副本更新为版本4。

The server still has all versions 1 through to whatever.

服务器仍然具有所有版本1到任何版本。

What you want to do, is create a new revision, revision number 5, which is identical to revision number 2.

您要做的是创建一个新版本,修订号为5,与修订号2相同。

cd /repo 
svn up -r 2 
cp /repo/file /tmp/file_2 
svn up -r 4 
cp /tmp/file_2 /repo/file 
svn commit -m "Making 5 from 2" 

If you ever change your mind and want 4 back, you can do so by creating revision 6 from revision 4.

如果您改变主意并希望4回来,您可以通过从修订版4创建修订版6来实现。

cd /repo 
svn up -r 4
cp /repo/file /tmp/file_4
svn up -r 5 
cp /tmp/file_4 /repo/file 
svn commit -m "Making 6 from 4" 

Happy hacking.

( there is of course a way to do the above in only 2 commands i believe, but its been a while since I did it and it can be a little confusing )

(当然有一种方法可以在我认为的2个命令中完成上述操作,但是自从我做了它已经有一段时间了,它可能有点令人困惑)

#4


3  

svn update -r 2 A.txt

This command will not delete any versions in the repository. It will set your working copy of A.txt to be revision 2. You can see this by doing

此命令不会删除存储库中的任何版本。它会将A.txt的工作副本设置为修订版2.您可以通过执行此操作来查看

> svn status -u A.txt
  *     2   A.txt

The output of this command show that you are viewing version 2, and that there are updates (that's the *).

此命令的输出显示您正在查看版本2,并且存在更新(即*)。

After doing this update, you will still be able to do "svn log" and see all the revisions.

执行此更新后,您仍然可以执行“svn log”并查看所有修订。

Performing "svn update A.txt" will return you to the latest version (in your case, r4).

执行“svn update A.txt”将返回最新版本(在您的情况下,r4)。

#5


2  

updating to an older rev will not delete your newer revs.

更新到较旧的转速不会删除您的较新转速。

so you could do svn up -r2 file, then svn up -r4 file.

所以你可以做svn up -r2文件,然后svn up -r4文件。

also, you wouldn't be able to commit the r2 file this way, because you'd have to update before committing, and you'd end up with r4 again.

另外,你不能以这种方式提交r2文件,因为你必须在提交前更新,你最终会再次使用r4。

#6


2  

"I don't want to use "svn update -r 2 A.txt" because this will delete all the revisions after r2, namely r3 and r4."

“我不想使用”svn update -r 2 A.txt“,因为这将删除r2之后的所有修订,即r3和r4。”

Uh... it won't, actually. Try it: do a regular svn update after the -r 2 one and you'll see the working copy updated back to r4.

呃......实际上它不会。试试看:在-r 2之后进行常规的svn更新,你会看到工作副本更新回到r4。

#7


1  

Update won't delete any revisions on the server. The only changes it makes are to your local working copy:

更新不会删除服务器上的任何修订。它所做的唯一更改是您的本地工作副本:

SVN Update Command

SVN更新命令

"brings changes from the repository into your working copy"

“将存储库中的更改带入您的工作副本”

"synchronizes the working copy to the revision given by the --revision switch"

“将工作副本同步到--revision开关给出的修订”