使用 SubversionWorking with Subversion

Subversion 是集中式版本控制系統,可讓您簽出集中式資料的單一主要複本。Subversion is the centralized version control system that enables you to check out a single main copy of the centralized data. 與 Git 相較之下,簽出 Subversion 存放庫不會複製整個存放庫,而只會取得該時間點的快照集。In contrast to Git, checking out a Subversion repository does not clone the entire repository, it only takes a snapshot at that point in time.

Subversion 使用「複製-修改-合併」模型,允許使用者同時處理相同的存放庫。Subversion uses a copy-modify-merge model to allow users to work on the same repository simultaneously. 這表示每位使用者都會建立集中式資料的本機或工作複本,接著就可以獨立處理它們。This means that each user creates a local, or working, copy of the centralized data, which they work on independently. 會以時間形式合併使用者對工作複本的變更。The changes to users working copies are merged in a chronological fashion.

例如,假設使用者 A 和使用者 B 都從遠端存放庫簽出複本,而且他們都會修改檔案。For example, imagine that User A and User B both check out a copy from the remote repository and they each modify files. 使用者 A 完成修改,並遠端進行認可。User A finishes the modifications and commits them remotely. 使用者 B 在認可其工作之前,必須將遠端中的變更更新至其工作複本,進而與使用者 A 的變更合併。Before User B commits their work, they must update their working copy with changes from the remote, merging in User A's changes.

下列各節中將探討如何在 Visual Studio for Mac 中使用 Subversion 進行版本控制。The following sections explore how Subversion can be used for version control in Visual Studio for Mac.

下圖說明 Visual Studio for Mac 透過 [版本控制] 功能表項目所提供的選項:The following image illustrates the options provided by Visual Studio for Mac by the Version Control menu item:

版本控制功能表項目

簽出...Checkout...

開始使用遠端 Subversion 存放庫之前,請簽出存放庫,以在本機電腦上建立該目錄的工作複本。Before starting to use a remote Subversion repository, check out the repo to create a working copy of that directory on your local machine.

若要了解如何在 Visual Studio for Mac 中使用 [簽出] 功能,請遵循設定 Subversion 存放庫一節中的步驟。To find out about using the Checkout feature in Visual Studio for Mac, follow the steps in the Setting up a Subversion repository section.

更新方案Update solution

使用遠端存放庫時,請務必記住,其他使用者可能正在修改檔案,進而導致您的工作複本過期。When using a remote repository, it's important to remember that other users may be modifying files, making your working copy outdated. 為了處理這項預期的衝突,我們建議在開始工作及認可之前,一律先將任何變更從存放庫提取到您的方案。In anticipation of conflicts, it's always recommended to pull any changes from the repository into your solution before starting work, and before committing. 若要執行提取變更,請選取 [版本控制] > [更新方案] 功能表項目。To do pull changes, select the Version Control > Update Solution menu item.

Review Solution and Commit (檢閱方案並認可)Review solution and commit

若要檢閱檔案中的變更,請使用每個文件上的 [變更]、[改動者]、[記錄] 和 [合併] 索引標籤,如下圖中所示:To review changes in files, use the Changes, Blame, Log, and Merge tabs on each document, as illustrated in the following image:

版本控制索引標籤

瀏覽 [版本控制] > [Review Solution and Commit] (檢閱方案並認可) 功能表項目,以檢閱專案中的所有變更:Review all changes in a project by browsing the Version Control > Review Solution and Commit menu item:

檢閱方案

這允許使用 [還原]、[建立修補檔案] 或 [認可] 的選項來檢視專案之每個檔案中的所有變更。This allows viewing all the changes in each file of a project with the option to Revert, Create Patch, or Commit.

若要將檔案認可到遠端存放庫,請按 [認可...],並輸入認可訊息,然後使用 [認可] 按鈕確認:To commit a file to the remote repository, press Commit..., enter a commit message, and confirm with the Commit Button:

認可檔案

這會將變更傳送至存放庫,而它們會在其中建立您的所有修改的新修訂。This will send the changes to the repository where they create the new revision of all your modifications.

請參閱See also