天天看點

Source Control HOWTO

轉載自 [url]http://www.cnblogs.com/margiex/archive/2005/09/08/232428.html[/url]

Source Control HOWTO

如何做源代碼控制

I have started writing a series of articles explaining how to do source control and the best practices thereof. See below for links to the individual chapters in this series. The Introduction explains my motivations and goals for writing this series.

我開始寫一系列解釋源代碼控制和最佳實踐的文章。這個系列都包含在以下的各個章節中。我在介紹裡面解釋了寫這個系列的動機和目的。

Please note: This is a work in progress. I plan to be adding new

chapters over time, and I may also be revising the existing chapters as I go along.

請注意:這是一個在不斷進行的工作。我打算随時添加新的篇章,并且我會修訂已經寫好的篇章。

Printer-friendly version:  Sorry folks, but I currently do not have this material available in a form which is more suitable for paper.  Someday I probably will, and when that happens, a link will appear here.

友善的列印版本:對不起,各位,但是我現在沒有适合列印的紙張樣式提供。或許過段時間可以,到那個時候,我這裡将會有一個連結的。

Chapter 0: Introduction

Our universities don't teach people how to do source control.  Our employers don't teach people how to do source control.  SCM tool vendors don't teach people how to do source control.  We need some materials that explain how source control is done.  My goal for this series of articles is to create a comprehensive guide to help meet this need.

我們的大學并不教我們如何做源碼控制,我們的雇主也不教我們如果做源碼控制,配置管理工具商家也不教我們如何做源碼控制。那我們就需要什麼材料來解釋如何做源碼控制。我寫這系列文章的目的就是要建立一個能解決這些需求的全面地使用指南。

What is source control?

Sometimes we call it "version control".  Sometimes we call it "SCM", which stands for either "software configuration management" or "source code management".  Sometimes we call it "source control".  I use all these terms interchangeably and make no distinction between them (for now anyway -- configuration management actually carries more advanced connotations I'll discuss later).

有的時候我們稱源碼控制為版本控制,有的時候我們又稱它為軟體配置管理,不管是“軟體配置管理”還是“源碼管理”,有些時候我們都稱為“源碼控制”,我總是交替的使用這些術語,并且沒有強調他們的差別。(當然,配置管理實際上包含了更多的内涵,我将在後面進行描述。)

By any of these names, source control is an important practice for any software development team.  The most basic element in software development is our source code.  A source control tool offers a system for managing this source code.

不管怎樣說這幾個名稱,源碼控制都是對軟體開發團隊極為重要的一個實踐。在軟體開發裡面最基本的元素就是我們的源代碼。源代碼控制工具就是一個用于管理這些代碼的系統。

There are many source control tools, and they are all different.  However, regardless of which tool you use, it is likely that your source control tool provides some or all of the following basic features:

現在有很多源碼控制工具,他們都是不相同的。但是,不管你用什麼工具,看起來現在有的源代碼控制工具都提供了下面列出的基本技能中的一些或者所有:

It provides a place to store your source code.

It provides a historical record of what you have done over time.

It can provide a way for developers to work on separate tasks in parallel, merging their efforts later.

It can provide a way for developers to work together without getting in each others' way.

提供一個空間存放源代碼。

提供随時間變化的曆史記錄。

提供一種方式:人們可以并行的進行被分離的任務,然後再合并。

在沒有其他的方式的時候,為開發人員提供一種協同工作的方式。

HOWTO 

My goal for this series of articles is to help people learn how to do source control.  I work for SourceGear, a developer tools ISV.  We sell an SCM tool called Vault.  Through the experience of selling and supporting this product, I have learned something rather surprising:

我的目标就是幫助人們學習怎樣做源碼控制。我使用SourceGear來工作,這是一個獨立軟體開發商提供的開發者工具。我們出售一種叫Vault的配置管理工具。通過對這個産品的出售和技術支援,我竟然學到很多讓人驚訝的東西。

Nobody is teaching people how to do source control.

沒有人在教人們怎樣做源碼控制。

Our universities often don't teach people how to do source control.  We graduate with Computer Science degrees.  We know more than we'll ever need to know about discrete math, artificial intelligence and the design of virtual memory systems.  But many of us enter the workforce with no knowledge of how to use any of the basic tools of software development, including bug-tracking, unit testing, code coverage, source control, or even IDEs.

我們的大學通常不會教我們怎麼做源碼控制。我們擁有計算機科學學位,我們知道我們曾被要求學離散數學、人工智能、虛拟存儲器系統設計。大多數的我們工作時都不具有怎樣用一些基礎的開發工具的知識,包括用缺陷追蹤、單元測試、代碼覆寫、配置管理,或者內建開發環境等等。

Our employers don't teach people how to do source control.  In fact, many employers provide their developers with no training at all.

我們的雇主不會教我們怎樣進行源碼控制。實際上,大多數的雇主都沒有為員工提供教育訓練。

SCM tool vendors don't teach people how to do source control.  We provide documentation on our products, but the help and the manuals usually amount to simple explanations of the program's menus and dialogs.  We sort of assume that our customers come to us with a basic background.

配置管理工具銷售商不會教人們怎樣做源碼控制。我們在産品裡面提供文檔,但是幫助和指南通常隻是簡單的解釋産品的菜單和對話框。

我們在一定程度上假設我們的使用者都是有一定技術背景的。

Here at SourceGear, our product is positioned specifically as a replacement for SourceSafe.  We assume that everyone who buys Vault already knows how to use SourceSafe.  However, experience is teaching us that this assumption is often untrue.  One of the most common questions received by our support team is from users asking for a solid explanation of the basics of source control.

這是SourceGear,我們的産品是特殊定位的類似Sourcesafe的産品。我們假設所有使用Vault的人都知道如何使用Sourcesafe。當然,經驗告訴我們假設僅僅是假設。最常見的是我們的客戶支援團隊總收到一些常見的版本控制問題。

Best Practice:  Use source control

最佳實踐:使用源碼控制

Some surveys indicate that 70% of software teams do not use any kind of source control tool. I cannot imagine how they cope.

一些調查指出,有70%的軟體團隊沒有使用任何類型的配置管理工具。我很難想象他們會怎樣應付。

Throughout this series of articles, I will be sprinkling Best Practices that will appear in sidebar boxes like this one. These boxes will contain pithy and practical tips for developers and managers using SCM tools.

We need some materials that explain how source control is done.  My goal for this series of articles is to create a comprehensive guide to help meet this need.

在後面一系列文章裡,我将将最佳實踐像這個工具條盒子那樣散布的顯示。這些盒子将包含提供給開發人員和管理者使用配置管理工具的時候的一些精華和實踐提示。

Somewhat tool-specific 

Ideally, a series of articles on the techniques of source control would be tool-neutral, applicable to any of the available SCM tools.  It simply makes sense to teach the basic skills without teaching the specifics of any single tool.  We learn the basic skills of writing before we learn to use a word processor.

理想的來說,關于源碼控制的一系列技術文章應該是與工具無關的,可以适用于任何配置管理工具。簡單的說就是隻講解版本控制或配置管理的流程或做法,而不是具體一個工具的使用。正像在我們用一個詞法處理器之前我們需要學習基礎的書寫技巧一樣。

However, in the case of SCM tools, this tool-agnostic approach is somewhat difficult to achieve.  Unlike writing, source control is simply not done without the assistance of specialized tools.  With no tools at all, the methods of source control are not practical.

當然,對于配置管理工具而言,不确定工具的方向是有點難以達到的。不同于書寫,源碼控制是必須借助特殊工具的。如果根本沒有工具,源碼控制的方法就難以實作。

Complicating matters further is the fact that not all source control tools are alike.  There are at least dozens of SCM tools available, but there is no standard set of features or even a standard terminology.  The word "checkout" has different meanings for CVS and SourceSafe.  The word "branch" has very different semantics for Subversion and PVCS.

更進一步複雜的狀況是不是所有的源碼控制工具都相似。市面上起碼有一打的工具可以使用,但是沒有統一功能或标準化術語。比如“checkout”在CVS和SourceSafe中的意義就不同。“branch”在Subversion和PVCS間有非常大的語義差別

So I will keep the tool-neutral ideal in mind as I write, but my articles will often be somewhat tool-specific.  Vault is the tool I know best, since I have played a big part in its design and coding.  Furthermore, I freely acknowledge that I have a business incentive to talk about my own product.  Although I will often mention other SCM tools, the articles in this series will use the terminology of Vault.

是以我在寫這些文章的時候我盡力對工具保持理性中立的立場,但是我的文章又經常會寫一點工具的細節。自從我将大部分的設計和編碼放到裡面開始,Vault是我知道的最好的工具。而且,我坦率地承認我有一個商業動機來描述我自己的産品。盡管我經常提到其他的配置管理工具,但是這系列文章還是會用到Vault的術語。

The world's most incomplete list of SCM tools 

Several SCM tools that I mention in this series are listed below, with hyperlinks for more information.

我在文章中提到的工具都列在下面,通過連結可以看到更多資訊。

n          Vault.  Our product.  'Nuff said.

n          SourceSafe.  Microsoft.  Old.  Loved.  Hated.

n          Subversion.  Open source.  New.  Neato.

n          CVS.  Open source.  Old.  Reliable.  Dusty.

n          Perforce.  Commercial.  A competitor of SourceGear, but one that I admire.  (一個SourceGear的競争對手,但是我很欣賞)

n          BitKeeper.  Commercial.  Uses a distributed repository architecture, so I won't be talking about this one much. (使用一個分布式資料庫結構,是以我不會更多的談及)

n          Arch.  Open source.  Distributed repository architecture.  Again, I spend most of my words here on tools with a centralized server. (分布式資料庫結構,我花了很多的文字在采用集中式伺服器的工具上)

This is a very incomplete list.  There are many SCM tools, and I am not interested in trying to produce and maintain and accurate listing of them all.

這僅僅是一個不完全的清單。現在有很多的配置管理工具,我沒有興趣要去嘗試維護和精确的列出他們。

Audience 

I am writing about source control for programmers and web developers.

我是在寫關于程式員和web開發者如何做源碼控制。

When we apply some of the concepts of source control to the world of traditional documents, the result is called "document management".  I'm not writing about any of those usage scenarios.

當我們在傳統的文檔中應用源碼控制的概念的時候,其結果是被稱為“文檔管理”。我不想寫任何關于這方面的操作細節。

When we apply some of the concepts of source control to the world of graphic design, the result is called "asset management".  I'm not writing about any of those usage scenarios.

當我們在傳統的應用圖形設計中應用源碼控制的概念的時候,其結果是被稱為“資産管理”。我也不是寫此方面的操作細節。

My audience here is the group of people who deal primarily with source code files or HTML files.

我的讀者是大量的使用源碼檔案或HTML檔案的人。

Warnings about my writing style

First of all, let me say a thing or two about political correctness.  Through these articles, I will occasionally find the need for gender-specific pronouns.  In such situations, I generally try to use the male and female variants of the words with approximately equal frequency.

首先,讓我說一兩件關于政治正确性的事情。在這些文章裡,我通常發現需要一些性别代詞。在有些情況下,我通常嘗試使用男性和女性變量保持一個均衡的頻率。

Discerning readers may notice my tendency to use female pronouns in examples which are positive and male pronouns in situations where the hypothetical person is a bonehead.  In part, I use this approach because it seems safer for me to aim my errors of political correctness in that direction.  I would also admit that this habit somewhat reflects my general belief that I was born a member of the gender which tends to evidence less character and virtue.

明眼的讀者可能注意到我的趨勢是在例子裡面使用女性代名詞表示積極的而男性在這種情況下被假設為笨蛋。部分地,我使用這種方式是盡量使我在“政治”正确性上看起來要安全一些。

我承認這樣做反映了我的一般看法,即我是一個在性别方面沒有很強觀點差别的人。

Second of all, please accept my apologies if my dry sense of humor ever becomes a distraction from the material.  I am writing about source control and trying to make it interesting.  That's like writing about sex and trying to make it boring, so please cut me some slack if I try to make you chuckle along the way.

第二,如果我的幹澀的幽默成為了分散注意力的東西,請接受我的道歉。我正在寫關于源碼控制并試圖使它變得有趣。這像描寫性并使它變得讨厭,是以如果我試圖使你發笑離開請你放我一馬。

Source control is a large topic, so there is much to be said.  I plan for the chapters of this series to be sorted very roughly from the very basic to the very advanced.  In the next chapter, I'll start by defining the most fundamental terminology of source control.

源碼控制是一個大的課題,這可以有很多話說。我計劃從基礎到進階分類機率的表述。在下一個章節,我将開始定義關于源碼控制的更多術語。

原文出處

[url]http://software.ericsink.com/scm/scm_intro.html[/url]

下一篇: Flume的Source

繼續閱讀