COSCUP 開源工作坊:Git workflows

56

Transcript of COSCUP 開源工作坊:Git workflows

Page 1: COSCUP 開源工作坊:Git workflows
Page 2: COSCUP 開源工作坊:Git workflows

COSCUP :Git Workflows

Hacking ThursdayCarl Su

CC BY 4.0

Page 3: COSCUP 開源工作坊:Git workflows

Hacking Thursday

Page 4: COSCUP 開源工作坊:Git workflows

• Skalde

• Hacker

• COSCUP Hacking Thursday

• H4

Page 5: COSCUP 開源工作坊:Git workflows

……

Page 6: COSCUP 開源工作坊:Git workflows
Page 7: COSCUP 開源工作坊:Git workflows
Page 8: COSCUP 開源工作坊:Git workflows

https://www.facebook.com/groups/hackingday/

https://hackingthursday.hackpad.com/

Page 9: COSCUP 開源工作坊:Git workflows

• Git Flow

• GitHub Flow

• GitLab Flow

Page 10: COSCUP 開源工作坊:Git workflows

Git

Page 11: COSCUP 開源工作坊:Git workflows

bare repository

• central repository

• .git

• GitHub bare repository

Page 12: COSCUP 開源工作坊:Git workflows

• working directory

• local repository

• git clone

• git init Git repository

Page 13: COSCUP 開源工作坊:Git workflows

Git

• git remote: bare repository

• git fetch: remote

• git pull: git fetch git merge

• git push: remote

Page 14: COSCUP 開源工作坊:Git workflows

https://goo.gl/YXhzdV

Page 15: COSCUP 開源工作坊:Git workflows

• Documents

• coscup2015_workshop

• bare repository

• h4_workshop.git

• .git

• john_h4_workshop, mary_h4_workshop

Page 16: COSCUP 開源工作坊:Git workflows

merge

Page 17: COSCUP 開源工作坊:Git workflows

John README push

Page 18: COSCUP 開源工作坊:Git workflows

Mary LICENSE push

Page 19: COSCUP 開源工作坊:Git workflows

Rejected (fetch first)

To /home/hackingthursday/Documents/h4_workshop.git ! [rejected] master -> master (fetch first)

Page 20: COSCUP 開源工作坊:Git workflows

Mary fetch push

Page 21: COSCUP 開源工作坊:Git workflows

Rejected (non-fast-forward)

To /home/hackingthursday/Documents/h4_workshop.git ! [rejected] master -> master (non-fast-forward)

Page 22: COSCUP 開源工作坊:Git workflows

Mary merge push

Page 23: COSCUP 開源工作坊:Git workflows

Merged (non-fast-forward)

Merge made by the 'recursive' strategy. README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 README.md

Page 24: COSCUP 開源工作坊:Git workflows

Fast-forward

• rebase

No fast-forward

• (merge)

• commit

fast-forward v.s. no fast-forward

Page 25: COSCUP 開源工作坊:Git workflows

pull --rebase

Page 26: COSCUP 開源工作坊:Git workflows

John LICENSE push

Page 27: COSCUP 開源工作坊:Git workflows

Mary README push

Page 28: COSCUP 開源工作坊:Git workflows

Rejected (fetch first)

To /home/hackingthursday/Documents/h4_workshop.git ! [rejected] master -> master (fetch first)

Page 29: COSCUP 開源工作坊:Git workflows

Mary pull --rebase push

Page 30: COSCUP 開源工作坊:Git workflows

Merged (pull --rebase)

First, rewinding head to replay your work on top of it...Applying: Add agenda section in README

Page 31: COSCUP 開源工作坊:Git workflows

• Git

• fetch pull

• Fast-forward no fast-forward

• Bare repository working directory

• merge rebase

Page 33: COSCUP 開源工作坊:Git workflows

feature branch

Page 34: COSCUP 開源工作坊:Git workflows

• Git

Page 35: COSCUP 開源工作坊:Git workflows

Page 36: COSCUP 開源工作坊:Git workflows

Git FlowA successful Git branching model

Page 38: COSCUP 開源工作坊:Git workflows

• master

• develop

Page 39: COSCUP 開源工作坊:Git workflows

• Feature branches

• Release branches

• Hotfix branches

Page 40: COSCUP 開源工作坊:Git workflows

Feature branches• develop

• develop

• feature/<featureA>

• add-copyright-holders

Page 41: COSCUP 開源工作坊:Git workflows

Release branches

• develop

• develop master

• release-* release/*

Page 42: COSCUP 開源工作坊:Git workflows

Hotfix branches

• master

• develop master

• hotfix-* hotfix/*

Page 43: COSCUP 開源工作坊:Git workflows

• develop

• release

• feature hotfix

• release

Page 44: COSCUP 開源工作坊:Git workflows

GitHub FlowIntroduced by GitHub

Page 45: COSCUP 開源工作坊:Git workflows

GitHub Flow

• fork / create a branch

• add commits

• open a pull request

• discuss and review your code

• deploy and merge

Page 46: COSCUP 開源工作坊:Git workflows

Fork repository or create a branch

Page 47: COSCUP 開源工作坊:Git workflows

Add commits

Page 48: COSCUP 開源工作坊:Git workflows

Open a pull request

Page 49: COSCUP 開源工作坊:Git workflows

Discuss and review your code

Page 50: COSCUP 開源工作坊:Git workflows

Deploy and merge

Page 51: COSCUP 開源工作坊:Git workflows

GitLab FlowProduction / Environment / Release branch

Page 52: COSCUP 開源工作坊:Git workflows

Production branch

• deploy

• production Git Flow master

Page 53: COSCUP 開源工作坊:Git workflows

Environment branch

Page 54: COSCUP 開源工作坊:Git workflows

Release branch

• hotfix cherry-pick

• production

Page 55: COSCUP 開源工作坊:Git workflows

Page 56: COSCUP 開源工作坊:Git workflows

• https://www.atlassian.com/git/tutorials/comparing-workflows/

• https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging

• http://nvie.com/posts/a-successful-git-branching-model/

• https://guides.github.com/introduction/flow/

• https://about.gitlab.com/2014/09/29/gitlab-flow/