暂时保存Subversion中未提交的更改(la“ git-stash”)

本文翻译自:Temporarily put away uncommitted changes in Subversion (a la “git-stash”)

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. 在对存储在Subversion版本库中的软件进行编程时,我经常修改一些文件,然后注意我想为我的主要工作做一些准备性的更改。 Eg 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, ie revert to the repository version, do some other changes, commit these, then "fetch back" my changes. 为了不混淆两个无关的更改,在这种情况下,我想“收藏”我的更改,即还原到存储库版本,进行其他更改,提交这些更改,然后“取回”我的更改。

git-stash allows to do just that. git-stash可以做到这一点。 Is there some way to do this with Subversion, either directly or with some plugin or script. 是否可以通过Subversion直接或使用某些插件或脚本来执行此操作。 Eclipse plugins would also be fine. Eclipse插件也可以。


#1楼

参考:https://stackoom.com/question/6WL0/暂时保存Subversion中未提交的更改-la-git-stash


#2楼

I have also wanted this feature. 我也想要这个功能。 I currently use TortoiseSVN. 我目前使用TortoiseSVN。

I have not found a hardfast solution except to export the tree, revert back to repository make my changes and commit, then compare the changes from the exported tree back into my source controlled directory using a tool like Beyond Compare. 除了导出树,还原到存储库进行我的更改并提交,然后使用Beyond Compare之类的工具将导出树中的更改返回到我的源代码控制目录中之外,我没有找到一个快速解决方案。

Or, another solution might be to branch from the HEAD to another directory, make your changes and the commit. 或者,另一个解决方案可能是从HEAD分支到另一个目录,进行更改并提交。 Once you're ready to merge those back to your other working copy, do an update and merge your changes. 一旦准备好将其合并回其他工作副本,请进行更新并合并您的更改。


#3楼

The easiest way would be to use a temporary branch, like this: 最简单的方法是使用临时分支,如下所示:

$ svn copy ^/trunk ^/branches/tempbranch
$ svn switch ^/branches/tempbranch
$ svn commit -m "Stashed"
$ svn switch ^/trunk
$ ... hack away in trunk ...
$ svn commit -m "..."
$ svn merge ^/branches/tempbranch .
$ svn rm ^/branches/tempbranch
$ ... continue hacking

This could (and probably should) be put in a script if done on a more regular basis. 如果可以更定期地执行,则可以(可能应该)将其放入脚本中。


#4楼

When I've got uncommitted changes from one task in my working copy and I need to switch to another task, I do one of two things: 当我对工作副本中的一个任务进行了未提交的更改并且需要切换到另一任务时,我将执行以下两项操作之一:

  1. Check out a new working copy for the second task. 为第二个任务签出新的工作副本。

    or 要么

  2. Start a branch: 开始分支:

     workingcopy$ svn copy CURRENT_URL_OF_WORKING_COPY SOME_BRANCH workingcopy$ svn switch SOME_BRANCH workingcopy$ svn commit -m "work in progress" workingcoyp$ svn switch WHATEVER_I_WAS_WORKING_ON_BEFORE 

I have some scripts that help to automate this. 我有一些脚本可以自动执行此操作。


#5楼

You can store your current changes with svn diff into a patch file, then revert your working copy: 您可以使用svn diff将当前更改存储到补丁文件中,然后还原工作副本:

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). 正如其他人指出的那样,这不适用于svn:properties和树操作(添加,删除,重命名文件和目录)。

Binary files could also give problems, I don't know how patch (or TortoiseSVN in this case handles them). 二进制文件也可能会带来问题,我不知道修补程序(或在这种情况下为TortoiseSVN)如何处理它们。


#6楼

another option is to copy your current checkout to a new directory and revert all your changes. 另一个选择是将您当前的结帐复制到新目录并还原所有更改。 this way you'll save the hassle of creating a temporary branch on your server—after all stashing is a local operation, which not everybody should see and can be done quite often. 这样,您将省去在服务器上创建临时分支的麻烦,因为所有存储都是本地操作,不是每个人都应该看到的,并且可以经常执行。

after committing your hotfix you can update your main working copy and delete your “stashing area” 提交修补程序后,您可以更新主工作副本并删除“存储区”

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章