bash SVN 仅导出更改的文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2998362/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SVN Export Only Changed Files
提问by Pete
I currently commit files to my SVN server (which is located on my web host), and from there I SSH in and export them to the working directory in my htdocs.
我目前将文件提交到我的 SVN 服务器(位于我的网络主机上),然后我从那里通过 SSH 将它们导出到我的 htdocs 中的工作目录。
As my application gets larger and larger, a full export is a waste of time. How can I only export the files that have been changed?
随着我的应用程序变得越来越大,完全导出是浪费时间。如何只导出已更改的文件?
svn export -r xxxx:HEAD http://svn/
Is a solution I had found, so maybe this can help? How can I automatically get the revision?
我找到了一个解决方案,所以这可能会有所帮助吗?如何自动获取修订版?
采纳答案by Cerin
I'm not sure if this is the same problem you're referring to, but when committing files for a web application I'm working on, I've used the svn2ftp.pySVN hook to automatically FTP modified files to a staging server. It was pretty easy to install and I've never had a problem with it.
我不确定这是否与您所指的问题相同,但是在为我正在处理的 Web 应用程序提交文件时,我使用了svn2ftp.pySVN 钩子来自动将修改后的文件通过 FTP 传输到登台服务器. 它很容易安装,我从来没有遇到过问题。
回答by Loftx
I have been using the following Bash script:
我一直在使用以下 Bash 脚本:
for i in $(svn diff --summarize -r 1:2 http://repo_path | awk '{ print }'); do p=$(echo $i | sed -e 's{http://repo_path/{{'); mkdir -p $(dirname $p); svn export $i $p; done
Similar to hudolejev's solution, it outputs the changes between revisions (1 and 2) in this case and loops over the files and folders.
与 hudolejev 的解决方案类似,它在这种情况下输出修订(1 和 2)之间的更改,并循环遍历文件和文件夹。
回答by User123342234
This works with the use of Tortoise SVN. I'm not sure it can be done without it.
这适用于 Tortoise SVN 的使用。我不确定没有它是否可以完成。
I had a similar issue where I had made changes to several thousand files (dont ask...it is an inherited problem!) out of 10's of thousands, so I didn't want to upload the whole directory or rely on winscp to correctly match the dates (since this server is in the US and im in AUS).
我有一个类似的问题,我对几千个文件进行了更改(不要问......这是一个继承的问题!),在成千上万个文件中,所以我不想上传整个目录或依赖 winscp 来正确匹配日期(因为该服务器在美国而我在澳大利亚)。
So I checked-in to SVN then via "Show Log" in Tortoise SVN. I then right-clicked on the most recent revision (although it could be any rev you live) and selected "compare with previous revision". I then selected all the files that appeared (CTRL-A) and right-clicked "export selection to" and BAM all the updated files in correct folder structure are saved and ready for upload.
因此,我通过 Tortoise SVN 中的“显示日志”签入了 SVN。然后我右键单击最新的修订版(尽管它可以是您所在的任何版本)并选择“与以前的修订版进行比较”。然后我选择了所有出现的文件(CTRL-A)并右键单击“导出选择到”,然后将正确文件夹结构中的所有更新文件保存并准备好上传。
回答by Daniel
I would do an SVN checkout into a local repositore, and then rsync the changed files into the web root. Or just do the checkout into the webroot and deny access to all .svn directories.
我会在本地存储库中执行 SVN 检出,然后将更改的文件 rsync 到 Web 根目录中。或者只是结帐到 webroot 并拒绝访问所有 .svn 目录。
回答by hudolejev
No pure-SVN solution exists that I am aware of, but you can try the following:
据我所知,不存在纯 SVN 解决方案,但您可以尝试以下操作:
svn update | egrep "^(A|U)[ ]+(.*)" | cut -b 2 | xargs -i cp -R "{}" /path/to/public_html
In your working directory, you get an update and parse the output -- svn update.
在您的工作目录中,您将获得更新并解析输出 -- svn update。
All files marked with Aand Uare candidates to copy -- egrep "^(A|U)[ ]+(.*)".
所有标有A和 的文件U都是要复制的候选文件 - egrep "^(A|U)[ ]+(.*)"。
Remove Aor Uto get the file name -- cut -b 2.
删除A或U获取文件名 - cut -b 2。
Copy files that changed since your last update -- xargs -i cp -R "{}" /path/to/public_html.
复制自上次更新以来更改的文件 - xargs -i cp -R "{}" /path/to/public_html。
(Sorry for clumsy shell-fu, still learning).
(抱歉笨拙的shell-fu,还在学习中)。
EDIT: Use cutinstead of tr(fixed)
编辑:使用cut代替tr(固定)
回答by Marek
I guess it's similar to an issue I had. Often I needed to ftp to my web server only those files that were changed recently. Rsync was not available on the web server, so I couldn't use it.
There is another one solution I use in my work. I use SVN in combination with Tracthat I have installed on my local server. Among of other Trac has a possiblity to show changes between two revisions or introduced in certain changeset. If you've never used Trac, please visit Trac project's home page to browse its repository. It's publicly available.
As an example I expanded the latest stable release (in the moment of writing this post), which is 0.12. The latest revision I can see is 10792. You can click the revision number to display revision log for this branch.
Now you can do two things:
我想这类似于我遇到的问题。通常,我只需要将最近更改的那些文件 ftp 到我的 Web 服务器。Rsync 在 Web 服务器上不可用,所以我无法使用它。
我在工作中使用了另一种解决方案。我将 SVN 与安装在本地服务器上的Trac结合使用。其中,Trac 可以显示两个修订版之间的更改或在某些更改集中引入的更改。如果您从未使用过 Trac,请访问 Trac 项目的主页以浏览其存储库。它是公开的。
例如,我扩展了最新的稳定版本(在撰写本文时),即 0.12。我能看到的最新版本是 10792。您可以单击版本号来显示该分支的版本日志。现在你可以做两件事:
- either select two revisions in Diffcolumn and click View changesbutton to see differences between them
- or click a small gear icon in Rev.column to see a changesetrelated to certain revision (see this page).
- 在Diff列中选择两个修订,然后单击查看更改按钮以查看它们之间的差异
- 或单击修订版列中的小齿轮图标以查看与特定修订版相关的变更集(请参阅此页面)。
In both cases you would see similar page with the list of modified files and nicely formatted changes between the old and the new files.
At the bottom of the page you can find links to download differences in two formats: unified diffand zip. The last one is exactly what you need - a zip archive containing only modified files. You can now unzip the archive and easily ftp modified files to a web server. In large projects it really saves time.
If you are not familiar with Trac please refer to Trac's documentation available on project's web pages or if you'd prefer you could get the book Managing Software Development with Trac and SubversionI found really useful.
在这两种情况下,您都会看到类似的页面,其中包含修改过的文件列表以及旧文件和新文件之间格式良好的更改。在页面底部,您可以找到两种格式的差异下载链接:统一差异和zip。最后一个正是您所需要的 - 一个仅包含修改过的文件的 zip 存档。您现在可以解压缩存档并轻松地将修改过的文件通过 ftp 传输到 Web 服务器。在大型项目中,它确实节省了时间。
如果您不熟悉 Trac,请参阅项目网页上提供的 Trac 文档,或者如果您愿意,可以阅读我发现使用 Trac 和 Subversion 管理软件开发这本书非常有用。
回答by LeastOne
A note for any other passersby ... if you'd like the same benefits of @User123342234's solution in working with Tortoise but would prefer not to commit the changes to your shared / remote repository before being able to export them. The same outcome can be achieved by creating a local svn repositoryusing Tortoise (a little known feature). You can then export your remote branch and import it into your local repository. Then export your local modified working copy of the remote repository over the working copy of your local repository and commit it. You can now use "Show Log" on the local repository to export the changes of the commit, all without having to first commit to the shared / remote repository. Not necessarily trivial, but was significantly helpful to me in at least once instance.
给任何其他路人的注意事项...如果您希望在使用 Tortoise 时获得与 @User123342234 的解决方案相同的好处,但不希望在能够导出更改之前将更改提交到您的共享/远程存储库。通过使用 Tortoise(一个鲜为人知的功能)创建本地 svn 存储库可以实现相同的结果。然后,您可以导出远程分支并将其导入本地存储库。然后将远程存储库的本地修改工作副本导出到本地存储库的工作副本并提交。您现在可以在本地存储库上使用“显示日志”来导出提交的更改,而无需先提交到共享/远程存储库。不一定微不足道,但至少在一次实例中对我有很大帮助。
回答by aimodify
svn2ftp 0.3- bash script. free to use, export files to ftp from svn repository. (cheking revisions) files: start.sh - script, settings.properties - svn, ftp, project properties.
svn2ftp 0.3- bash 脚本。免费使用,将文件从 svn 存储库导出到 ftp。(检查修订)文件:start.sh - 脚本,settings.properties - svn、ftp、项目属性。

