简体   繁体   中英

How do I revert an SVN commit?

I have found various examples of how to revert an SVN commit like

svn merge -r [current_version]:[previous_version] [repository_url]

or

svn merge -c -[R] .

But neither of them seems to work. I tried those commands and checked the files that were changed by hand.

How do I revert a commit with revision number 1944? How do I check that the revert has been done (without looking in the actual file to the changes have been reverted)?

I have found various examples of how to revert an SVN commit like

svn merge -r [current_version]:[previous_version] [repository_url]

or

svn merge -c -[R] .

But neither of them seems to work. I tried those commands and checked the files that were changed by hand.

How do I revert a commit with revision number 1944? How do I check that the revert has been done (without looking in the actual file to the changes have been reverted)?

I have found various examples of how to revert an SVN commit like

svn merge -r [current_version]:[previous_version] [repository_url]

or

svn merge -c -[R] .

But neither of them seems to work. I tried those commands and checked the files that were changed by hand.

How do I revert a commit with revision number 1944? How do I check that the revert has been done (without looking in the actual file to the changes have been reverted)?

I have found various examples of how to revert an SVN commit like

svn merge -r [current_version]:[previous_version] [repository_url]

or

svn merge -c -[R] .

But neither of them seems to work. I tried those commands and checked the files that were changed by hand.

How do I revert a commit with revision number 1944? How do I check that the revert has been done (without looking in the actual file to the changes have been reverted)?

I have found various examples of how to revert an SVN commit like

svn merge -r [current_version]:[previous_version] [repository_url]

or

svn merge -c -[R] .

But neither of them seems to work. I tried those commands and checked the files that were changed by hand.

How do I revert a commit with revision number 1944? How do I check that the revert has been done (without looking in the actual file to the changes have been reverted)?

I have found various examples of how to revert an SVN commit like

svn merge -r [current_version]:[previous_version] [repository_url]

or

svn merge -c -[R] .

But neither of them seems to work. I tried those commands and checked the files that were changed by hand.

How do I revert a commit with revision number 1944? How do I check that the revert has been done (without looking in the actual file to the changes have been reverted)?

I have found various examples of how to revert an SVN commit like

svn merge -r [current_version]:[previous_version] [repository_url]

or

svn merge -c -[R] .

But neither of them seems to work. I tried those commands and checked the files that were changed by hand.

How do I revert a commit with revision number 1944? How do I check that the revert has been done (without looking in the actual file to the changes have been reverted)?

I have found various examples of how to revert an SVN commit like

svn merge -r [current_version]:[previous_version] [repository_url]

or

svn merge -c -[R] .

But neither of them seems to work. I tried those commands and checked the files that were changed by hand.

How do I revert a commit with revision number 1944? How do I check that the revert has been done (without looking in the actual file to the changes have been reverted)?

I have found various examples of how to revert an SVN commit like

svn merge -r [current_version]:[previous_version] [repository_url]

or

svn merge -c -[R] .

But neither of them seems to work. I tried those commands and checked the files that were changed by hand.

How do I revert a commit with revision number 1944? How do I check that the revert has been done (without looking in the actual file to the changes have been reverted)?

I have found various examples of how to revert an SVN commit like

svn merge -r [current_version]:[previous_version] [repository_url]

or

svn merge -c -[R] .

But neither of them seems to work. I tried those commands and checked the files that were changed by hand.

How do I revert a commit with revision number 1944? How do I check that the revert has been done (without looking in the actual file to the changes have been reverted)?

I have found various examples of how to revert an SVN commit like

svn merge -r [current_version]:[previous_version] [repository_url]

or

svn merge -c -[R] .

But neither of them seems to work. I tried those commands and checked the files that were changed by hand.

How do I revert a commit with revision number 1944? How do I check that the revert has been done (without looking in the actual file to the changes have been reverted)?

I have found various examples of how to revert an SVN commit like

svn merge -r [current_version]:[previous_version] [repository_url]

or

svn merge -c -[R] .

But neither of them seems to work. I tried those commands and checked the files that were changed by hand.

How do I revert a commit with revision number 1944? How do I check that the revert has been done (without looking in the actual file to the changes have been reverted)?

I have found various examples of how to revert an SVN commit like

svn merge -r [current_version]:[previous_version] [repository_url]

or

svn merge -c -[R] .

But neither of them seems to work. I tried those commands and checked the files that were changed by hand.

How do I revert a commit with revision number 1944? How do I check that the revert has been done (without looking in the actual file to the changes have been reverted)?

I have found various examples of how to revert an SVN commit like

svn merge -r [current_version]:[previous_version] [repository_url]

or

svn merge -c -[R] .

But neither of them seems to work. I tried those commands and checked the files that were changed by hand.

How do I revert a commit with revision number 1944? How do I check that the revert has been done (without looking in the actual file to the changes have been reverted)?

Note that the svn merge command reverts a commit in the sense of having another commit undoing your changes, but keeping your wrong commit in the history.

In the case you are a Subversion system administrator (with command line access) and you have to revert a very big mistake (for example, someone committed something that should not be committed for no reason in the world), and if you want to try to completely drop a commit at any cost, even at the risk of destroying the repo:

Step 1. Identify your repository on your server

First of all identify your repository on your server's filesystem.

Let's assume that the pathname is /repo . But it may be /home/svn/myrepo or something like that.

The filesystem structure should be something like this:

$ ls -la /repo
total 16
drwxr-xr-x.   6 svn svn   86 10 feb  2020 .
drwxrwx---. 145 svn svn 4096 22 giu 16.14 ..
drwxr-xr-x.   2 svn svn   54 10 feb  2020 conf
drwxr-sr-x.   6 svn svn  253 17 giu 11.25 db
-r--r--r--.   1 svn svn    2 10 feb  2020 format
drwxr-xr-x.   3 svn svn 4096 10 feb  2020 hooks
drwxr-xr-x.   2 svn svn   41 10 feb  2020 locks
-rw-r--r--.   1 svn svn  229 10 feb  2020 README.txt

Let's also assume that your user is called svn like in the above example.

NOTE : if you don't know what this is talking about, you probably have not your own Subversion server and this answer may be not useful for your case. Please try other answers (where you just need to have the URL of the server, without physical access).

Step 2. Export your good history

Let's assume that your wrong revision is 100 and your correct version is 99 :

svnadmin dump -r 1:99 /repo > export.dump

Step 3. Backup and re-init your repository

Create a backup of your repository and initialize it again:

mv              /repo /repo.bak
mkdir           /repo
svnadmin create /repo

Step 4. Import your good history again

svnadmin load /repo < export.dump

Now, make sure to fix your permissions with the right user:

chown -R svn:svn /repo

Is everything working? That's all! Good for you!

BUT at this point there are interesting chances you have destroyed your whole repository. For example, you may no longer be able to checkout, or, your Subversion web application (Phabricator?) may scream with weird error messages, or, you could have killed a thousand kittens by mistake in the process.

If something goes wrong stay ready with your disaster recovery:

Disaster recovery

If a disaster happen:

mv /repo     /repo.fail
mv /repo.bak /repo

Hoping to be useful.

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