Day eighteen
Previously, I shared how to use 'git add', 'git commit', 'git revert', 'git reset' ...etc. So today I'm going to share a more advanced usage, 'git branch'.
之前的文章陸陸續續的跟大家分享了如何使用'git add', 'git commit', 'git revert', 'git reset'等等的基礎操作,所以今天要開始跟各位介紹git 比較進階的用法,git branch。
What's 'git branch'? Simply speaking, it's like a concept of a tree. From the root, to branches, and then to leaves. Before forking, we share the mutual bulk, but from the moment they fork, they start a distinct growing.
什麼是'git branch'呢? 簡單來說,git 有點像是一棵樹的概念,從樹根開始到樹枝甚至到樹葉,而branch就是分支的概念,就像樹支的分支,在他們分支之前,他們擁有共同的一部分,但從分支的那一刻開始,彼此就擁有著不一樣的生長。
So why would we use branch?
那為什麼要使用'git branch'呢?
The concept and usage of git has been universally utilised. For example, if we develop on our own computer. Let's say that we've finished a big function and we are pretty sure that it works well and smoothly. Normally we call it as 'master' branch.
However, from it onwards, we would like to develop anohter big function. But we are not sure that if the newly to-be-developed function will affect the current perfect one, we could create a whole new branch called 'feature branch'. On this branch, we could make commits upons what it requres until we finish this big new function. And then we could merge this newly developed one from the current one. (I will share what merge is in my later article.)
'git branch'的概念以及用法非常的廣泛,從本機端開發來舉例,假如今天我們已經完成了一個大的功能,並且確定這一個功能在運作上沒有問題,這個分支通常稱為預設或主線(master)
然而,從這個功能開始,我們想要在開發另外一個大功能,但因為我們不知道新開發的東西會不會影響到已經確定沒有問題的功能,所以我們可以開一個分支,稱為功能分支。在這個分支上,我們可以隨著我們的進度一步一步的commit,直到最後我們完成了這個新開發的大功能,然後再從主線master,將這一個已經完成的功能支線做合併(合併的部分之後會再跟大家分享)。
Another example on the developing process of a company. A company might have three branches, one called 'developing branch', and another one called 'test branch', and the other one called 'master branch'.
Developers push their codes to 'developing branch', and after initially testing the function without any problems, the code is allowed to be pushed to 'test branch', and after some testing performed by some quality specialist, the code is finally allowed to be pushed to 'master branch' called stable reversion for release as memtioned before.
從公司端的開發流程來舉例,一間公司可能會有三個分支,例如開發分支(development), 測試分支(test), 然後是最終的發行分支(master)。
由各部門開發完成的功能會先推到開發分支(development),在初步測試都沒有問題之後,開發分支的功能才可以推到測試分支(test),在相關部門測試完沒有問題之後,才可以推到發行分支(master),然後就如之前介紹的,此分支上的為穩定版。
As described above, normally the progress on 'developing branch' is massively ahead of 'master branch', but it's only allowed to be released after all those testing without any problems.
如以上的解說,很可能開發分支的進度已經領先發行分支很多了,但因為整個流程的重重測試,大部分都會測到沒有問題才會上市。
So, branch could be a critical part of the whole reversion control, isn't it?
這樣看來,branch是不是版本控制中不可或缺的一環呢?
See you guys.
我們明天見!