Onshape 提供將文件版本或工作區 (合併的來源) 中的變更與目前使用中文件工作區 (合併的目標) 合併的機制。
當您將所選的來源 (工作區或版本) 與目前使用中的目標 (工作區) 合併時,您可以 (1) 使用來源來取代目標中的所有變更,(2) 將來自來源的所有變更合併到目標中,或是 (3) 保留所有來自目標的變更。此外,您可以使用這 3 個相同的策略來指定要如何合併工作區中的各別獨立分頁。
您無法選擇分頁中個別的變更。必須保留、合併或取代來自每個分頁的所有變更。
Onshape’s branching feature enables the creation of new workspaces for design experimentation without impacting other workspaces. Changes can be easily copied from one branch to another using Merge.
This document has two workspaces: the original design in the Main workspace and another workspace named Square Base. The team wants to move forward with the Square Base. With the Main workspace active, right-click on the Square Base workspace and select Merge into current workspace.
The Merge dialog is sorted into two sections: tabs with changes and tabs without changes. At the top, you can select an overall merge strategy for changes. Below the Keep and Replace options, there is a link to Compare with base. This compares that branch with the state the document was in at the branch point.
Keep retains the target workspace tab, leaving it in its current condition. This means no changes are made to that tab on the Main branch during this merge.
Merge combines changes from both branches. This option is only available for Part Studios and assemblies, and only if both branches contain changes for a specific tab. It is not available for drawings or other tab types. In Part Studios, changes include creating, modifying, or deleting features, configuration inputs, materials, or appearances. In assemblies, changes include modifying, adding, or removing components, mate connectors, or configurations. It is important to use this option carefully, as changes from different branches can be incompatible, causing errors.
Replace updates the target with the source. If any changes exist in the target branch, they are completely overwritten. Next to each changed tab, you can override the overall strategy with one specific to the tab. Any tab with a differing merge strategy is indicated with yellow.
Choose the overall merge strategy of Replace. This replaces the original base with the square one in the Main branch. Click the Show or Hide merges icon to toggle the visibility of merge lines.
When activated, the graph depicts each merge operation visually. Merge lines connect each merge from its source to its target, clearly showing how changes are combined and propagated throughout the document’s history. If the changes to the design are unexpected or not desired, you can always undo the merge by restoring the workspace to the last action before the merge.
This example showed a merge between two workspaces, but you can also merge a version from another branch into the current workspace using the same process.
-
開啟「版本與歷程」面板。
-
系統會以深藍色強調顯示目前使用中的工作區 (也就是目標;下方圖片中的 Main)。若要將另一個工作區或版本 (也就是來源;下方圖片中的 B1) 合併到目標中,請在來源上按右鍵,然後選取 [合併至目前的工作區]:
-
合併的對話方塊開啟,顯示從來源和目標分支分叉之後的變更:
-
選擇性地選取「整體合併策略」:
-
Keep [Target] - Changes in the Target are kept.
-
Merge changes - This is the default. Changes in both the Source and Target are merged.
在合併變更時,合併的基準會是分支分叉處的變更 (例如,建立分支處的版本 ),或如果有的話,會是相同來源分支先前合併至這個目標的最後一個點 (假定並未還原合併的情況下)。
-
Replace with [Source] - Changes in the Source will replace changes in the Target.
-
-
Optionally, select a merge strategy for each tab to override the Overall merge strategy. The merge strategy options are the same as the Overall merge strategy, except where a tab is created or deleted, or for tab types that do not support the Merge changes from both option (see the first tip below). In these instances, you can only elect to (1) Keep [Target] or (2) Replace with [Source]:
-
A change with a green checkmark icon indicates edits to the tab in that workspace are kept in the Target workspace after the merge.
-
A change with a red x icon indicates discarded edits (deleted features, for example) in the workspace tab are kept in the Target workspace after the merge.
-
A change denoted with an exclamation mark icon indicates the tab will not exist in the Target workspace after the merge.
-
An information icon indicates that for this tab type, changes from separate branches cannot be merged (a drawing, for example). You must select either the Target (Keep [Target]) or Source (Replace with [Source]). See Tabs where changes from separate branches cannot be merged.
-
-
Click Merge. In the Versions and history graph, the merge lines show that branch B1 has been merged into the Main branch.
All merges are displayed explicitly in the Versions and history graph, which updates automatically as changes are made to the document.
Showing and hiding merge lines
To make the Versions and history graph easier to visualize, toggle the Show/Hide merges and Show/Hide automatic versions buttons as needed:
Merge lines example
The example below shows a complex Versions and history graph with several branches. Each branch was created from the Main workspace, and then individual work was done on each branch. As work on each branch was completed, the branches were merged back into Main. The flow of lines to and from the Main branch shows the merging workflow, making it easy to see which changes were merged when.
When selecting tabs to merge, the Merge changes from both option is available for all tab types except Drawings and PCB Studios. When working with Drawings and PCB Studios, it is recommended you work in one workspace (branch) and merge from that branch into other branches. Working on two or more branches simultaneously may result in lost changes when you merge from one branch to another.
例如:
-
在 Main (目標) 中建立一個工程圖 (Drawing 1),然後插入一個零件。
-
建立一個版本 (V1),然後從這個版本產生一個分支 (來源 B1)。
-
在 B1 工作區中,於 Drawing 1 分頁內將尺寸加入到零件的一個邊上。
-
在 Main 工作區中,將尺寸加入到同一 Drawing 1 分頁內相同零件的不同邊上。
-
將 B1 (來源) 工作區的變更合併到 Main (目標) 工作區中。
-
在合併對話方塊中為 Drawing 1 分頁選擇「分頁合併策略」,系統會提示您選擇下列之一:
-
Keep Main - This keeps the Drawing 1 tab from the Main workspace. The dimension added in the Main workspace is retained and the dimension added in B1 is overwritten.
-
Replace with B1 - This Replaces the Main workspace Drawing 1 tab with the B1 workspace drawing 1 tab. The dimension added in the Main workspace is overwritten, replaced with the dimension added in B1.
在上方的兩個案例中,系統會保留一個尺寸並覆寫另一個尺寸。若要避免此種情況,請僅在一個工作區 (例如 Main) 中對 Drawing 1 分頁進行所有操作,然後在將 B1 合併到 Main 時,選擇「保留 Main」,這樣就可以保留所有在 Drawing 1 分頁中的變更。
If the target and source branches are the same, and all tabs use a Keep merge strategy, no updates are needed. The Merge button will be unavailable.
- To replace the target branch with the source branch, change the Tab merge strategy to Replace.
-
Click Merge.
When working with protected branches, the working branch must be kept up-to-date with the protected branch before a merge can occur. If the Merge button in the Merge dialog is disabled and you see the Workspace protections are enabled warning:
- Close the Merge dialog to return to the document.
- Select the working branch in the Versions and history graph.
- With the working branch selected, right-click the protected branch and select Merge into current workspace from the context menu.
- In the Merge dialog, confirm that you are merging the protected branch into the working branch, then click Merge. The working branch is updated with the changes from the protected branch.
- In the Versions and history graph, select the protected branch.
- With the protected branch selected, right-click the working branch and select Merge into current workspace.
- You should now be able to merge your changes into the protected branch.
Branches with outdated versions of FeatureScript cannot be merged. If one or more branches uses an old version of FeatureScript, you will see a warning message about this version mismatch in the Merge dialog.
-
Click the Update FeatureScript icon to update the FeatureScript versions in both the target and source branches to the latest.
- Click Update now in the window that opens to complete the update.
- Click Merge.
Branches cannot be merged if the document is in use. If another user has the document open, or if you have the document open in multiple browser windows or tabs, you will see an error that lists the users and number of open instances.
- Ensure that you and other users have closed out of the document.
- The dialog will automatically refresh, and you can click Update now.
- If Onshape is unable to verify that the document is not in use (i.e., due to network connectivity issues) you will see the warning below:
- Click the Retry icon in the dialog to attempt verification again.
- Click Merge.
Merges cannot be completed while updates are still in progress. Try again later after the current update is complete.
-
Since a merge cannot be undone using the undo icon, after a merge is performed, a message opens where you can click a link to revert the merge. This message persists when switching tabs, workspaces, and comparing between workspaces, so you can inspect the results of the merge. Press the close icon to accept the merge and exit the message:
如果在合併文件之後,您或其他使用者變更了文件,然後您又還原了合併,則變更會遺失。
-
如果沒有任何變更存在會需要合併來源與目標,在合併對話方塊中的選項會僅是 (1) 保留 [目標] 或 (2) 以 [來源] 來取代。預設的選項是以 [來源] 來取代:
-
Click the Compare with base link in the merge dialog to open a new browser tab where both Source and Target are compared. See Comparing for more information.
-
若要合併一或多個分頁的變更而不改變目前工作區中的任何其他項目,請為「整體合併策略」 選擇「保留 [目標]」,然後根據您的需求為每個分頁選擇「以 [來源] 來取代」或「合併來自雙方的變更」。
-
在合併對話方塊中對分頁的排序是將有變更的分頁排在上方,沒有變更的分頁則在下方。接著每個部分會根據分頁在分頁列中由左到右的位置從上到下排列,會先顯示目標分支,然後再顯示來源分支,不會顯示資料夾。
當您將所選的來源 (工作區或版本) 與目前使用中的目標 (工作區) 合併時,在來源中所做的全部變更將會合併至目標中,包括所有其他的特徵、分頁等等。
-
Tap the Versions and history icon to open the panel:
-
Select the target branch (the branch to merge into) in the Versions and history panel.
- With the target branch still selected, tap the three-dot menu to the right of the source branch (the branch to merge), then tap Merge into current workspace.
All changes made in the Source are merged into the currently active workspace (Target). This action is recorded in the Versions and history panel entries and you can restore from a previous record to reverse the merge action, if necessary. For more information about restoring versions, see Document Management.
當合併包含工程圖、圖片、PDF 或其他不是 Part Studio 或 Assembly 分頁的工作區時,如果同時在來源與目標的分頁中做出變更,則在來源分支中的變更會覆寫在目標分支中的變更。例如,如果您同時更新兩個分支 (來源與目標) 中的 PDF 分頁,然後合併分支,則合併之後,來源分支中的 PDF 會出現在目標分支中。
All merges are displayed explicitly in the Versions and history graph, which updates automatically as changes are made to the document.
Showing and hiding merge lines
To make the Versions and history graph easier to visualize, toggle the Show/Hide merges and Show/Hide automatic versions buttons as needed:
Merge lines example
The example below shows a complex Versions and history graph with several branches. Each branch was created from the Main workspace, and then individual work was done on each branch. As work on each branch was completed, the branches were merged back into Main. The flow of lines to and from the Main branch shows the merging workflow, making it easy to see which changes were merged when.
當合併包含工程圖 (在工程圖分頁中) 的工作區時,合併過程中會以有變更的工程圖為優先。明確地說,當來源與目標分支中的工程圖同時有變更時,會以來源工程圖為優先:
- 如果在來源中的工程圖變更而目標中的工程圖並未變更,則會將來源中的工程圖複製到目標中,取代目標中的工程圖。任何並出現在來源中的目標工程圖內的變更則會被覆寫。
- 如果來源工作區的工程圖沒有變更 (相較於目標中的工程圖),則在目標中的工程圖會保持不變。
建議您在一個工作區的一個工程圖 (分支) 上進行操作,然後將該分支合併至另一個分支中。同時在一或多個分支上操作工程圖可能會導致將工程圖從一個分支合併到另一個分支時,變更的遺失。