For faster navigation, this Iframe is preloading the Wikiwand page for 分支 (版本控制).

分支 (版本控制)

版本控制软件配置管理中,分支(英語:Branching)是由某個版本的程式碼或軟體物件中建立複製版本,在分支出來後的兩個版本,可以獨立進行修改。

分支會形成樹狀結構,也被稱為treesstreamscodelines。原始的版本,稱為父分支(parent branch)或是上游分支(upstream branch)。分支出來的複本,稱為子分支(Child branches)。作為最源頭,沒有父分支的分支,稱為主幹(trunk)或主線(mainline)[1]

分散式版本控制系統(例如Darcs英语Darcs)中,分支和存放版本的儲存庫(repository)是一樣的。在這類系統,複製一份儲存庫的複本和分支是一樣的。

軟體進行分支後,之後有可能會再將分支合并回父分支。常見的是將修改內容合併回主幹(有可能主幹不是父分支)。若某個分支不打算合併(例如曾由第三方授權,授權內容不相容,因此已重新授權英语relicensing,或是用在不同用途上),會稱為分叉(fork)。

使用分支的原因

[编辑]

建立分支可以讓各部份的程式碼可以平行開發[2]。大型專案會有不同的參與者,例如開發人員、build管理者,以及软件质量保证人員等。甚至需要維護針對不同作業系統的不同發行版。分支可以讓參與者在不破壞基礎代碼穩定性的情形下,將修改和基礎代碼隔離,再進行程式錯誤修正、新機能英语Feature (software design)開發[3]軟件版本整合等。這些修改可以在測試完成後,再合併回主線。

開發分支

[编辑]

開發分支(development branch)或開發樹(development tree)的程式碼是指正在软件开发,但還沒有正式發行的程式碼。若在开放源代码社群中,「正式發行」不是那麼直覺,因為任何人隨時都可以取出(check out)需要的版本,不管是不是在開發分支中都可以取出。一般而言,最終會是下一個主要版本的分支就是開發分支。不過也常常同時開發多個機能,因此存在多個開發分支。

有些版本控制軟體會針對主要的開發分支有特殊的命名,例如在CVS中稱為MAIN,在git中則稱為master[4]

陰影分支或魔術分支

[编辑]

cvc英语cvc system(開源軟體,整合rPath開發的版本控制系統)及CVSNT英语CVSNT中,可以針對上游的分支建立陰影分支或魔術分支,在小修改的維護上比較方便。

儲存庫的複製

[编辑]

分散式版本控制中,可以複製整個儲存庫(以及其中的分支),之後再進行開發。Monotone(mtn)、Mercurial(hg)[5]git[6]稱為clone。

相關條目

[编辑]

參考資料

[编辑]
  1. ^ Berczuk, Steve; Appleton, Brad. Software Configuration Management Patterns: Effective Teamwork, Practical Integration. Addison-Wesley. 2003 [2007-05-24]. ISBN 0-20174117-2. (原始内容存档于2020-10-30). 
  2. ^ Appleton, Brad; Berczuk, Stephen; Cabrera, Ralph; Orenstein, Robert. Streamed Lines: Branching Patterns for Parallel Software Development (- PDF). Hillside. 1998-02-08 [2009-08-12]. (原始内容存档 (PDF)于2020-10-25). 
  3. ^ Bailey, Derick. Part 1: Why. Branch-Per-Feature Source Control. Los techies. 2009-07-15 [2009-08-12]. (原始内容存档于2020-07-29). 
  4. ^ Git Branching Branches in a Nutshell. [2020-07-29]. (原始内容存档于2020-12-20). 
  5. ^ clone. [2020-07-29]. (原始内容存档于2018-07-01). 
  6. ^ git-clone. [2020-07-29]. (原始内容存档于2020-12-14). 
{{bottomLinkPreText}} {{bottomLinkText}}
分支 (版本控制)
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?