用来自别人的修改更新你的工作副本

图 5.11. 已经完成更新的进度对话框

已经完成更新的进度对话框


Periodically, you should ensure that changes done by others get incorporated in your local working copy. The process of getting changes from the server to your local copy is known as updating. Updating may be done on single files, a set of selected files, or recursively on entire directory hierarchies. To update, select the files and/or directories you want, right click and select TortoiseSVNUpdate in the explorer context menu. A window will pop up displaying the progress of the update as it runs. Changes done by others will be merged into your files, keeping any changes you may have done to the same files. The repository is not affected by an update.

进度对话框使用颜色代码来高亮不同的更新行为

紫色

新项已经增加到你的工作副本中。

深红

你的工作副本中删除了多余项,或是你的工作副本中丢失的项被替换。

绿色

版本库中的修改与你的本地修改成功合并。

亮红

来自版本库的修改在与本地修改合并时出现了冲突,需要你解决。

黑色

你WC中的没有改动的项被来自版本库中新版本所更新。

这是默认的配色方案,但你可以通过设置对话框来定制这些颜色。参考“TortoiseSVN 颜色设置”一节获得详情。

If you get any conflicts during an update (this can happen if others changed the same lines in the same file as you did and those changes don't match) then the dialog shows those conflicts in red. You can double click on these lines to start the external merge tool to resolve the conflicts.

When the update is complete, the progress dialog shows a summary of the number of items updated, added, removed, conflicted, etc. below the file list. This summary information can be copied to the clipboard using Ctrl+C.

The standard Update command has no options and just updates your working copy to the HEAD revision of the repository, which is the most common use case. If you want more control over the update process, you should use TortoiseSVNUpdate to Revision... instead. This allows you to update your working copy to a specific revision, not only to the most recent one. Suppose your working copy is at revision 100, but you want it to reflect the state which it had in revision 50 - then simply update to revision 50. In the same dialog you can also choose the depth at which to update the current folder. The terms used are described in “检出深度”一节. The default depth is Working copy, which preserves the existing depth setting. You can also choose whether to ignore any external projects in the update (i.e. projects referenced using svn:externals).

小心

If you update a file or folder to a specific revision, you should not make changes to those files. You will get “out of date” error messages when you try to commit them! If you want to undo changes to a file and start afresh from an earlier revision, you can rollback to a previous revision from the revision log dialog. Take a look at “Roll back (Undo) revisions in the repository”一节 for further instructions, and alternative methods.

更新到版本在你偶尔要看看你的项目在早前某时刻是什么样子的时候很有用。但通常,更新单个文件到之前的版本不是一个好主意,因为这会使你的工作副本处于不一致的状态。如果你要更新的文件已经改了名,你可能甚至发现该文件从你的工作副本中消失了,因为早期的版本中不存在这个名字的文件。如果你只是简单地想要一个旧版本文件的本地副本,最好是在该文件的日志对话框中使用右键菜单另存版本为...命令。

多文件/文件夹

如果你在资源管理器中选择了多文件和文件夹,然后选择更新,这些文件/文件夹一个接一个的被更新。TortoiseSVN确保所有的来自同一版本库的文件/文件夹被更新到同一个版本!即使在更新过程中发生了另一个提交。

本地文件已经存在

有时在你试图更新的时候,更新失败,提示信息说已经有一个同名的本地文件。通常发生在Subversion试图检出一个新增的受控文件时,发现一个未受控的同名文件已经在工作路径中存在。Subversion绝不会覆盖一个未受控的文件——因为它有可能有你需要的东西,却碰巧与另一个开发者新提交的文件重名了。

如果你得到这个错误信息,解决的方法就是把本地的未受控文件重命名。在完成更新之后,你再检查被重命名的文件是不是还需要。

如果你一直得到错误,使用TortoiseSVN检查修改来列出所有有问题的文件。这样你可以一次性解决它们。