用來自別人的修改更新你的工作副本 -开发者知识库

用來自別人的修改更新你的工作副本 -开发者知识库,第1张

圖 5.11. 已經完成更新的進度對話框

用來自別人的修改更新你的工作副本 -开发者知识库,已經完成更新的進度對話框,第2张

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 TortoiseSVN → Update 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 TortoiseSVN → Update 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 → 檢查修改來列出所有有問題的文件。這樣你可以一次性解決它們。

最佳答案:

本文经用户投稿或网站收集转载,如有侵权请联系本站。

发表评论

0条回复