COSCUP 開源工作坊:Git workflows

Preview:

Citation preview

COSCUP :Git Workflows

Hacking ThursdayCarl Su

CC BY 4.0

Hacking Thursday

• Skalde

• Hacker

• COSCUP Hacking Thursday

• H4

……

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

https://hackingthursday.hackpad.com/

• Git Flow

• GitHub Flow

• GitLab Flow

Git

bare repository

• central repository

• .git

• GitHub bare repository

• working directory

• local repository

• git clone

• git init Git repository

Git

• git remote: bare repository

• git fetch: remote

• git pull: git fetch git merge

• git push: remote

https://goo.gl/YXhzdV

• Documents

• coscup2015_workshop

• bare repository

• h4_workshop.git

• .git

• john_h4_workshop, mary_h4_workshop

merge

John README push

Mary LICENSE push

Rejected (fetch first)

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

Mary fetch push

Rejected (non-fast-forward)

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

Mary merge push

Merged (non-fast-forward)

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

Fast-forward

• rebase

No fast-forward

• (merge)

• commit

fast-forward v.s. no fast-forward

pull --rebase

John LICENSE push

Mary README push

Rejected (fetch first)

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

Mary pull --rebase push

Merged (pull --rebase)

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

• Git

• fetch pull

• Fast-forward no fast-forward

• Bare repository working directory

• merge rebase

feature branch

• Git

Git FlowA successful Git branching model

• master

• develop

• Feature branches

• Release branches

• Hotfix branches

Feature branches• develop

• develop

• feature/<featureA>

• add-copyright-holders

Release branches

• develop

• develop master

• release-* release/*

Hotfix branches

• master

• develop master

• hotfix-* hotfix/*

• develop

• release

• feature hotfix

• release

GitHub FlowIntroduced by GitHub

GitHub Flow

• fork / create a branch

• add commits

• open a pull request

• discuss and review your code

• deploy and merge

Fork repository or create a branch

Add commits

Open a pull request

Discuss and review your code

Deploy and merge

GitLab FlowProduction / Environment / Release branch

Production branch

• deploy

• production Git Flow master

Environment branch

Release branch

• hotfix cherry-pick

• production

• 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/