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.
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.
To make a new revision of A.txt that is equal to revision 2:
svn up -r HEAD
svn merge -r HEAD:2 A.txt
svn commit
Also see the description in Undoing changes.
The command svn up -r 4
only updates your local copy to revision 4.
The server still has all versions 1 through to whatever.
What you want to do, is create a new revision, revision number 5, which is identical to revision number 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.
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 )
I don't have a lot of experience with Subversion so please excuse me if this method doesn't work in this environment.
In this situation I follow these steps:
This way when you go through your file history you will see something like:
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
> 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 *).
After doing this update, you will still be able to do "svn log" and see all the revisions.
Performing "svn update A.txt" will return you to the latest version (in your case, r4).
updating to an older rev will not delete your newer revs.
so you could do svn up -r2 file
, then svn up -r4 file
.
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.
"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."
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.
Update won't delete any revisions on the server. The only changes it makes are to your local working copy:
SVN Update Command
"brings changes from the repository into your working copy"
"synchronizes the working copy to the revision given by the --revision switch"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With