2009-07-17 svn tagging and branching

svn 是一種使用之前會討厭,
但使用過以後你已經不能缺少的開發環節 (情況和測試驅動開發(TDD)一樣)

在"使用過" 並愛上的青況之下,
你很容易便會提起興趣學習進階的 branch 和 tag 的功能了
但如果沒有, 直接跳過就好了

對於使用者來說, tag 和 branch 建立之後, 你會發現 svn 好像複製了 trunk 的檔案到另一個地方
所以你的在 trunk 的 commit 不會對tag 和 branch 的資料做成影響, 相反如是
如果你瀏覽你的 repo, 你便可以發現你的 code 都在 trunk 資料夾之下(如果正常的設定之下)
上一層便可以看到 tags 和 branches 資料夾, 甚至是 releases 資料夾

但tagging 並不會對你的檔案系統和硬碟做成壓力
因為它只會建立連結到 tags, 而不會建立另一組的檔案
另一面說, 就是 svn 提供一個快速的 tag 和 branch, 令你樂於使用, 就好像 commit 一樣

從底層技術的層面來說, tagging 和 branching 是一樣的
唯一的不同是我們, 或者開開發團隊使用的方法和習慣
簡單說, branching 是分作一個階段的除蟲, 可以是一個新加的一個功能, 一些大型的功能上, 或者結構上的修改
相反, tagging 便隨意得多
我會建立日期 tag, 在我將我的code 上傳到共用開發機做相容性測試之前
以確保我可以快速拿回前天的上傳, 令共用的開發機不會因為我今日的 code 而影響到其他人的測試, 開發
當然, 你也可以因應你的需要而建立不同的 tag

最後提示一下, 假如你轉到 branches 或 tag 工作的話
記得要轉回trunk, 否則你的 commit 到會轉到 tag 或 branch 旗下了

Svn is a thing that you will hate it before use,
but cannot live without after first trial. ( same as test driven development here.)

With such environment, you will got the interest to use and learn tagging and branching.
But if not, just skip this blog post.

Tagging is cheap in CPU time and hardisk space.
It just create links to tagged versions of files, which do not create some extra files copies.
In return, svn provide a speedy tagging and branching, which will not block the development process, just like commits.
Tag and branch act like copying your trunk to another folder (although it is not real in file system, stated above),
so you have separate versions of code and their commit will not affect each other.
If you browse the repo of your head, most probably you will find your code live in trunk folder.
Moving up a level, you will find tags and branches folder, an in some config, even a releases folder.

In real backend, tagging is the same as branching, techically.
But like we do commit in trunk, we do tagging in tags folder and branch in branches folder.

So the only difference is how we, or the team, is using it as common practises.
In simple, branching is for bug fix of releases, new major function added, which is usually a huge change in structure or functionality.
But tagging is more "relax".
I will tag codes with datetime, before deploy to staging server, so I can always revert to previous deploy status on staging server.

But last to remind, if you have encountered so case you want to switch to branches or tag version,
remember to switch back to trunk or you will commit to branches instead of normal working trunk version.

Enjoy svn!

Google