玩轉 git-flow 工作流 - 分支解析
概述
搞開發的相信大部分人 git 天天都在用,那麼一般我們在實際工程當中,遵循一個合理、清晰的 Git 使用流程,是非常重要的。否則,每個人都提交一堆雜亂無章的 commit,項目很快就會變得難以協調和維護。那麼是如何來規範整個流程的呢 ;
標準其實很多,這裏我們介紹下 Gitflow;
什麼是 Gitflow
那麼針對這個規範我們來看下如何在實際使用中來應用整個流程
分支說明
主要分兩種 主分支 和 支援性分支
● 主分支 : 分支目錄為單層,分支永久保留
○ develop : 當 feature branches 開發完成後,提供測試時,請合併到此,此分支不做任何的程序修改和變更集,只接受 master 和 feature branches 的合併
○ master : 永遠處在 production-ready 狀態
● 支援性分支 : 分支層級爲雙層,合併後且沒使用可刪除
○ feature branches : 新功能開發,分支的建立都以 master 為來源
○ hotfix branches : 臨時需修改的 bug ,分支的建立都以 master 為來源
○ release branches: 提供 Marketing 測試,預計要上線的版本,分支的建立都以 master 為來源,且在合併要測試的 feature branches,合併完成後請設定 Tag,Tag 的內容為合併的 feature branches
分支的來源和合並
● 主分支
■ 來源 : master, feature branches
■ 合併 : 無
○ master
■ 來源 : 無
■ 合併 : release branches, develop
● 支援性分支 : 分支層級為雙層
○ feature branches
■ 來源 : master
■ 合併 : release branches, develop
■ 來源 : master
■ 合併 : release branches, develop, master
○ release branches
■ 來源 : master, feature branches
■ 合併 : master
支援性分支命名
● feature branches : 依功能命名
○ ex: 開發的新功能爲 FeedbackDashboard,請命名爲 feature/FeedbackDashboard
● hotfix branches : 依修改的 bug 命名
○ ex: 修改 Invoice 的顯示錯誤,請命名爲 hotfix/Invoice
● release branches : 因為合併多個 feature branch,需依日期命名
○ ex: release/20171013
分支對應環境
● 主分支
○ develop : 開發環境
○ master : 生產環境
● 支援性分支
○ feature branches : 無
○ hotfix branches : 無
○ release branches : 沙箱環境
Git 常用指令
請安裝 Git Windows : https://git-scm.com/download/win
● 分支合併
○ git merge feature/xxx --no-ff
○ :ws!
● 同步遠端分支
○ git remote update
○ git remote update origin --prune
● 加入 dll 到 Git
○ git add xxx.dll -f
● 還原本機所有變更集
○ git reset --hard HEAD~
● 建立 Tag
○ git tag -a tagName
● 同步 Tag 到遠端
○ git push origin tagName
● 查詢 Tag 的內容
○ git show tagName
● 刪除 Tag
○ git push -d origin tagname
○ git -d tagname
本文由 Readfog 進行 AMP 轉碼,版權歸原作者所有。
來源:https://mp.weixin.qq.com/s/O5-_qQrTzypJMS7NZH2iDA