暫時保存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” 提交修補程序後,您可以更新主工作副本並刪除“存儲區”

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