Temporarily put away uncommitted changes in Subversion (a la "git-stash")

sleske picture sleske · Oct 12, 2009 · Viewed 83.8k times · Source

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.

Answer

Walter Mundt picture Walter Mundt · Aug 2, 2010

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.)