讀書筆記:《Version Control With Git》

地一章 簡介git

首先提到了VCS(Version Control System)的基本功能:github

Although the authors and users of each tool might debate esoterics, each system address the same issues: develop and maintain a repository of content, provider access to historical editions of each datium, and record all changes in a log.算法

其次提到了Linus對於BitKeeper的替代品的指望。其實這些指望也能夠看做Git的特色:dom

  • Facilitate distributed development(支持分佈式開發)
    也就是人們不須要隨時的和中心倉庫同步。人們能夠獨立、並行的開發,甚至在一些離線的本地環境中也不會遇到問題。分佈式

  • Scale to handle thousands of developers(能夠支持上千名開發人員)ide

  • Perform quickly and efficiently(高效)
    相較於集中化的版本控制系統而言,Git每次只保存增量,無疑更有優點。
  • Maintain integrity and trust(保持完整和可信)
  • Enforce accountability(可靠性)
  • Immutability(不變性)
  • Atomic transactions(原子事物)
  • Support and encourage branched development(支持並鼓勵分支開發)
  • Complete repositories(完整的代碼庫)
  • A clean internal design(乾淨的內部設計)
  • Be free, as in freedom(免費)

那麼Git時如何知足這些需求的呢?哪些需求時咱們的平常開發中也會遇到的呢?有哪些最佳實踐呢?遺憾的是,這一章中並無進一步進行闡述。學習

Git-Scm的文檔中咱們可能找到一些提示:ui

  • Git直接記錄快照而不是增量
  • 近乎全部的操做都是本地執行。這一點使得人們能夠在離線狀態下進行開發。準確的說,不僅是開發,大部分的版本控制操做均可以在離線狀態下完成!
  • 時刻保持完整性。這一特性是機遇SHA1加密算法對於每一個對象提供數字指紋來完成的。
  • 多數操做僅添加操做。

接下來,我會帶着上面的問題略過第二章(安裝),直接進入第三章(開始)進行學習。加密

=======================================
附錄一個經常使用的協做開發流程(參與已有項目開發):設計

  • 在Github上fork一個branch
  • Git clone到本地
  • 添加upstream: git remote add upstream (地址),能夠經過git remote -v來查看是否添加成功。這主要是爲了可以pull到其餘人的change。
  • 建立新的分支:git branch branch_name。並切換到對應branch:git checkout branch_name。經過git branch能夠查看當前的分支。
  • 開發
  • git add . 添加全部的change。能夠經過git status來查看相關狀態
  • git commit -m "message"。
  • git push origin branch_name。
  • 在github上發一個pull request
  • code review並重復開發、添加、commit、push的步驟直到被merge。
相關文章
相關標籤/搜索