Reputation: 20242
I am using SVN and I have updated my project.
By accident, I selected 'Keep Mine' rather than 'Keep Their' when resolving a conflict. Then, I tried to revert the changes manually but that didn't work and now the file is in a bad state.
How can I redo the update? Can I revert to my state before the update and then update again?
Upvotes: 1
Views: 152
Reputation: 45087
If I'm understanding you correctly, then your file contains a mixture of your local changes (uncommitted) plus some upstream changes (merged into your working copy, but not committed back to the repo). If that is indeed the case, then there's unfortunately not an easy way out. Using svn revert
would wipe out all uncommitted changes, and that's probably not what you want. Here's what I would do to try and recover the original file.
First and foremost, make a backup copy of the file before you try anything else. That should protect against further data loss.
Now, get copies of three different versions of the file: your current copy, the revision in the repository, and the revision that you tried to merge in. You will have to use the diffs between these three files to identify which changes in your working copy are your local changes and which are merged-in changes. A graphical utility that can do three-way diffs is useful here but if you don't have one, you can also use the two-way diffs between the original version and your local version, and between the original version and the merged version. The idea is to identify your local changes and then hand-merge them into a fresh copy of the file. Some of your local changes may have been lost or altered due to the merge, so you will probably have to re-create some of the content (hopefully not much).
It's a manual process, but it's probably the best that you'll be able to do. Your level of success will likely depend on the scope of your local changes and how much those local changes overlapped with the merged-in changes. To avoid this in the future I recommend only doing a merge when there are no local changes in your working copy. If that can't be avoided, then you can do a svn diff
to save a patch of your local changes before the merge, giving you a way to go back to the pre-merge state if needed (svn revert
then apply the patch).
Upvotes: 1