Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent of "git reset --hard" with SVN

Tags:

I would like to revert my SVN central repository, not a working copy, from revision M to revision N ( M > N ), like a git reset --hard

How can I do that ?

like image 418
Quentin Avatar asked Aug 11 '11 14:08

Quentin


People also ask

Should you use git reset hard?

First, it's always worth noting that git reset --hard is a potentially dangerous command, since it throws away all your uncommitted changes. For safety, you should always check that the output of git status is clean (that is, empty) before using it.

Can you use SVN with git?

Git SVN is a feature in Git that allows changes to move between a Subversion and a Git repository. Git SVN is a good feature to use if you need to allow changes to go between Git and SVN repositories.

What is git reset -- hard command?

Summary. To review, git reset is a powerful command that is used to undo local changes to the state of a Git repo. Git reset operates on "The Three Trees of Git". These trees are the Commit History ( HEAD ), the Staging Index, and the Working Directory.


2 Answers

Here you go.

svn revert --recursive . 
like image 110
Xing Avatar answered Oct 01 '22 12:10

Xing


EDIT

the other answer (https://stackoverflow.com/a/24500425/520162) seems to be a better solution than the one proposed by me. Check that one!


On the client, it's simple:

svn checkout -r <revision> url://path/to/repo 

should do it.

If you're on the server (like your edited question says), it depends what you want to achieve.


If you want to throw away all revisions after N, do a

svnadmin dump -r1:N yourrepo > repo.dump 

then, delete the old repo and create a new one

svnadmin create newrepo svnadmin load newrepo < repo.dump 

If you want to keep your repo, check out N on a client and commit to the server, so that N is the latest state.


Third one: set up a branch starting from N and work on that one.

like image 45
eckes Avatar answered Oct 01 '22 13:10

eckes