简体   繁体   中英

Subversion: How do I commit a Update To Revision?

I have a situation where:

  • Developer is working on SVN project.
  • Person checks out SVN project, walks away, kid/cat/wife sits/dools/sleepwalks/whatever at computer and inserts gobbledygook asdfg-code. Person commits project.
  • Developer sees bad files and Update To Revision back to the last working version

All is well untill the developer wants to commit the project. If the developer has made changes to the file in question, it will be committed just fine. BUT if not - the dev only Update To Revision and made no further changes - that file will not be commited, and any updates to the project will render the gobbledygook asdfg-code file to you.

Question : If I only 'Update To Revision' a file, how do I commit it again without manually editing the file?

I think you have chosen the wrong route around the problem.

Rather than changing what revision you are looking at, you should have:

  1. Updated to latest revision including the rubbish
  2. found the rubbish commit on the revision log and chosen revert this change
  3. committed the cleanup with or without any other changes you had to your working copy

So what you would do now is to update to the latest version (applying the rubbish change) and revert their change which brings you back in line. Pretty much as if they made the change while you where working and didn't have the change in the first place.

You can only commit when your code is up to date with the head of the working branch/trunk.

SVN won't make a branch for you dynamically at this point of earlier revision, you have to choose to make a branch, or to update to the head.

If you are on windows, and are using TortoiseSVN:

  1. Right click on the dir, select "TortoiseSVN > Merge..."
  2. Select "Merge a range of revisions"
  3. In "Url to merge from" select the current branch (the one which is checked out in the current dir)
  4. In "Revision range to merge" type or select ("Show log") the latest wrong revision
  5. Mark "Reverse merge" checkbox

Then after the merge, just commit! :)

You can simply undo changes by using the following

svn merge -c -RevisionWhichWasWrong ^/trunk

The RevisionWhichWasWrong is the latest which you've checked in. After that simply do

svn commit 

and that's it.

BTW: It's not posssible to checkin if you have never made changes to the contents of files.


1- Update to special version that you want to be the last version.

2- Export this version to a folder.

3- Update working copy to last version.

4- Overwrite exported files and folders into working copy folder.

5- Commit!

Good question! As far as i know it's only possible by manually adding a white space or something to the file so subversion sees the file as changed. After that it creates a new revision.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM