sle*_*ske 305 svn versioning
在编写存储在Subversion仓库中的软件时,我经常修改一些文件,然后注意我想为我的主要工作做一些预备性更改.例如,在实现新功能时,我注意到一些可能对我有帮助的重构.
为了不混合两个不相关的更改,在这些情况下,我想"收起"我的更改,即恢复到存储库版本,执行一些其他更改,提交这些更改,然后"获取"我的更改.
git-stash允许这样做.是否有一些方法可以直接或使用某些插件或脚本使用Subversion.Eclipse插件也没关系.
Wal*_*ndt 327
这篇博文建议使用diff和patch.
git stash
差不多了 svn diff > patch_name.patch; svn revert -R .
git stash apply
变 patch -p0 < patch_name.patch
请注意,这不会隐藏元数据更改或(我认为)目录创建/删除.(是的,svn与目录内容分开跟踪,与git不同.)
kni*_*ttl 175
您可以将当前更改存储svn diff
到修补程序文件中,然后还原工作副本:
svn diff > stash.patch
svn revert -R .
Run Code Online (Sandbox Code Playgroud)
在实现预备功能之后,您可以使用修补程序实用程序应用修补程序:
patch < stash.patch
Run Code Online (Sandbox Code Playgroud)
正如其他人已经注意到这将无法使用svn:properties
树操作(添加,删除,重命名文件和目录).
二进制文件也可能会出现问题,我不知道补丁(或者TortoiseSVN在这种情况下如何处理它们).
ben*_*din 67
当我从工作副本中的一个任务获得未提交的更改并且我需要切换到另一个任务时,我会执行以下两项操作之一:
查看第二个任务的新工作副本.
要么
开始分支:
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
Run Code Online (Sandbox Code Playgroud)我有一些脚本可以帮助自动执行此操作.
Jes*_*erE 42
最简单的方法是使用临时分支,如下所示:
$ 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
Run Code Online (Sandbox Code Playgroud)
如果更经常地进行,这可以(并且可能应该)放在脚本中.
sni*_*nip 21
从1.10.0(2018-04-13)开始,您有实验svn shelve
命令.(TortoiseSVN支持命令)它只是保存补丁和应用的辅助工具,因此它具有与svn diff
+ 相同的限制patch
(即无法处理二进制文件和重命名).(编辑:看起来二进制支持即将发布到下一版本)
编辑^ 2: 使用1.11.0(2018-10-30发布),支持二进制文件.搁置重命名的文件仍然不受支持.1.11中的搁架与1.10创建的搁板不兼容.
设计说明可以在他们的Wiki上找到.
$ svn x-shelve --help
x-shelve: Move local changes onto a shelf.
usage: x-shelve [--keep-local] SHELF [PATH...]
Save the local changes in the given PATHs to a new or existing SHELF.
Revert those changes from the WC unless '--keep-local' is given.
The shelf's log message can be set with -m, -F, etc.
'svn shelve --keep-local' is the same as 'svn shelf-save'.
The kinds of change you can shelve are committable changes to files and
properties, except the following kinds which are not yet supported:
* copies and moves
* mkdir and rmdir
Uncommittable states such as conflicts, unversioned and missing cannot
be shelved.
To bring back shelved changes, use 'svn unshelve SHELF'.
Shelves are currently stored under <WC>/.svn/experimental/shelves/ .
(In Subversion 1.10, shelves were stored under <WC>/.svn/shelves/ as
patch files. To recover a shelf created by 1.10, either use a 1.10
client to find and unshelve it, or find the patch file and use any
1.10 or later 'svn patch' to apply it.)
The shelving feature is EXPERIMENTAL. This command is likely to change
in the next release, and there is no promise of backward compatibility.
Valid options:
-q [--quiet] : print nothing, or only summary information
--dry-run : try operation but make no changes
--keep-local : keep path in working copy
(...)
$ svn x-unshelve --help
x-unshelve: Copy shelved changes back into the WC.
usage: x-unshelve [--drop] [SHELF [VERSION]]
Apply the changes stored in SHELF to the working copy.
SHELF defaults to the newest shelf.
Apply the newest version of the shelf, by default. If VERSION is
specified, apply that version and discard all versions newer than that.
In any case, retain the unshelved version and versions older than that
(unless --drop is specified).
With --drop, delete the entire shelf (like 'svn shelf-drop') after
successfully unshelving with no conflicts.
The working files involved should be in a clean, unmodified state
before using this command. To roll back to an older version of the
shelf, first ensure any current working changes are removed, such as
by shelving or reverting them, and then unshelve the desired version.
Unshelve normally refuses to apply any changes if any path involved is
already modified (or has any other abnormal status) in the WC. With
--force, it does not check and may error out and/or produce partial or
unexpected results.
The shelving feature is EXPERIMENTAL. This command is likely to change
in the next release, and there is no promise of backward compatibility.
Valid options:
--drop : drop shelf after successful unshelve
(...)
$ svn help | grep x-
x-shelf-diff
x-shelf-drop
x-shelf-list (x-shelves)
x-shelf-list-by-paths
x-shelf-log
x-shelf-save
x-shelve
x-unshelve
Run Code Online (Sandbox Code Playgroud)
我不知道用svn做一个简单的方法.老实说,我建议使用git-svn
git repo作为svn工作副本,并使用git stash
它.只需更换git pull
与git svn rebase
和git push
与git svn dcommit
实际上,你可以保持90%的git的工作流程,但仍然可以说话的SVN服务器.