While programming software stored in a Subversion repo, I often modify some files, then notice that I'd like to do some preparatory change for my main work. E.g. while implementing new functionality, I notice some refactoring which might help me.
In order not to mix two unrelated changes, in these cases I'd like to "stow away" my changes, i.e. revert to the repository version, do some other changes, commit these, then "fetch back" my changes.
git-stash allows to do just that. Is there some way to do this with Subversion, either directly or with some plugin or script. Eclipse plugins would also be fine.
The stash command takes the uncommitted changes in your working directory, both the updated tracked files and staged changes, and saves them. However, the changes aren't finished, and you need to switch to a different branch to quickly fix a bug before continuing on with the current feature.
In order to stash untracked files, add the “–include-untracked” option to your “git stash” initial command. Alternatively, you can simply use the “-u” which is equivalent to the untracked longer version.
Right-click a file in the Current Folder browser and select Source Control > Revert using SVN. In the Revert Files dialog box, choose a revision to revert to. Select a revision to view information about the change such as the author, date, and log message. Click Revert.
This blog post advises using diff and patch.
git stash
approximately becomes svn diff > patch_name.patch; svn revert -R .
git stash apply
becomes patch -p0 < patch_name.patch
Note that this doesn't stash metadata changes or (I think) directory creates/deletes. (Yes, svn tracks those separately from directory contents, unlike git.)
You can store your current changes with svn diff
into a patch file, then revert your working copy:
svn diff > stash.patch svn revert -R .
After you’ve implemented your preparatory feature, you can then apply your patch with the patch utility:
patch < stash.patch
As others have noted this will not work with svn:properties
and tree operations (add, remove, rename files and directories).
Binary files could also give problems, I don’t know how patch (or TortoiseSVN in this case handles them).
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