Skip to content

GitHub & GitLab#

    %%{
        init: { 
            'logLevel': 'debug', 
            'theme': 'base', 
            'gitGraph': {'mainBranchOrder': 2 }, 
            'themeVariables': { 
                'commitLabelColor': '#ffffff', 
                'commitLabelBackground': '#000000', 
                'commitLabelFontSize': '14px'
            } 
        } 
    }%%
    gitGraph
    checkout main
    commit id: "start"
    commit id: "add feature1"
    branch feature1 order: 3
    commit id: "create feature1"
    commit id: "pull request"
    commit id: "code review"
    checkout main
    merge feature1 id: "MERGE1"
    commit id: "add feature2"
    branch feature2
    commit id: "create feature2"
    commit id: "pull request2"
    commit id: "code review2"
    checkout main
    branch feature3 order: 4
    commit id: "create feature3"
    commit id: "fix error"
    checkout main
    merge feature2 id: "MERGE2"
    commit
    checkout feature3
    commit id: "pull request3"
    commit id: "code review3"
    checkout main
    merge feature3  id: "MERGE3"
    commit
    %%{
        init: { 
            'logLevel': 'debug', 
            'theme': 'base', 
            'gitGraph': {'mainBranchOrder': 3, 'parallelCommits': false }, 
            'themeVariables': {
                'commitLabelColor': '#ffffff', 
                'commitLabelBackground': '#000000', 
                'commitLabelFontSize': '14px'
            }
        }
    }%%
    gitGraph
    commit
    branch pre-production order: 2
    checkout pre-production
    commit
    branch production order: 1
    checkout production
    commit
    checkout main
    branch feature1 order: 4
    checkout feature1
    commit id: "merge request"
    commit id: "code review"
    checkout main
    merge feature1 id: "MERGE1"
    checkout pre-production
    merge main
    checkout production
    merge pre-production tag: "1.0.0"
    branch error1 order: 5
    commit id: "merge request2"
    commit id: "code review2"
    checkout main
    merge error1 id: "MERGE2"
    checkout pre-production
    merge main
    checkout production
    merge pre-production tag: "1.0.1"

Comparison#

GitHub flow GitLab flow
優點
  • 不同於Git flow那般需要創建多個不同的分支,GitHub flow以主分支為主並利用 pull request來進行程式碼的整合
  • 適合CI和小型專案的開發
  • 有著原本Git flow和GitHub flow的優點
缺點
  • 如果專案稍大可能會造成過多的pull request,這導致管理跟code review需要更多的時間,且也可能造成更多的merge conflict
  • 不適合需要長時間的功能的開發,這會導致workflow更加複雜且提升整合出問題的風險
  • 學習曲線較GitHub flow複雜
  • Git的歷史紀錄會因為merge request的累積變得難以閱讀

References:#