xecon2015 :: [1-3] 김덕홍 - git workflow with github

106

Upload: xpressengine

Post on 16-Apr-2017

734 views

Category:

Software


4 download

TRANSCRIPT

insanehong@NAVER working with the IoT Platform

Korea Git User Group FounderLike Git, Node.js, Javascript, OpenSource

“인세인님 GIT 강의를 해주세요!”

이 사단(??) 의 시작은 이 한마디로 시작 되었습니다.

50 minute

8 hour

ONLY BASIC

아 몰랑~~

제가 오늘 하려는 얘기는

많은 개발자들이git 을 어려워 합니다.

Why or How?

시간이 지나도 달라지는 건 없고…

Why or How?

저도 아직 git 의 가진 기능의 일부 밖에 쓰지 못합니다.

Q1. Why?

A1. Fast & Compact

DELTA

SNAPSHOT

GITDELTA

Everything is Local

CVCS• 버전 관리의 대표적인 방식• 하나의 서버와 다수의 클라이언트• CVS, Subversion, Perforce• 서버가 다운될 경우 버전관리 불가능

• 서버문제로 스냅샷을 제외한 이력의 손실 가능

DVCS• CVCS 의 문제를 해결하기 위해 고안

• Git, Mecurial, Bazaar, Darcs 등• 다수의 원격 저장소• 다양한 workflow 사용가능

DELTA vs SNAPSHOT

A2. Branch

BRANCH@SVN

특정 커밋(리비전)을 가리키는

부르기 쉬운 이름을 정하는 것

BRANCH@GIT

여기서 잠깐!!

git 은 모든것을 파일로 관리 합니다.

$ cat .git/HEADref: refs/heads/master

$ tree .git/refs.git/refs !"" heads #   $"" master $"" tags

2 directories, 1 file

$ cat .git/refs/heads/master1a8236f284791342fb8340f9e38531fa471e2823

자 지금부터 확인 들어갑니다.!!

HEAD master 1a8236f

ref: refs/heads/master 1a8236f

e0d5a92 23a1ef8 1a8236f

master branch

8e9a5f4

7914811 2557c94

두 branch의공통 parent commit

topic brach

A3. Powerful Command

add, commit, push, branch, checkout, merge, rebase, fetch, pull, reset, stash, tag, status, cherry-pick, log, diff, bisect, blame…

평소에 자주 사용하는 명령어만 해도….

Q2. How ?

이 발표는 특정회사에 대한 간접광고를 절대 담고 있지 않습니다.

Performance IntakeSelf Install

Quick Internal

$ echo "hello world" >> README.md

Workingdirectory

index

objectdatabase

README.mdhello world

Workingdirectory

index

objectdatabase

README.mdhello world

blob 3b18e512

README.md 3b18e512

$ git add README.md

headerblob 11\u0000

contenthello word

sha1sum3b18e512dba79e4c8300dd08aeb37f8e728b8dad

BLOB OBJECT

$ git is-files --staged #index 에 등록된 파일 확인 100644 3b18e512dba79e4c8300dd08aeb37f8e728b8dad 0 README.md

$ tree .git/objects.git/objects/ !"" 3b #   $"" 18e512dba79e4c8300dd08aeb37f8e728b8dad !"" info $"" pack

blob(zlib compressed SHA1)

Workingdirectory

index

objectdatabase

README.mdhello world

blob 3b18e512 tree 43b71c90 README.md commit e0d5a92d add README.md file

README.md 3b18e512

$ git commit -m "add README.md file"

headertree 37\x00

content100644 README.md 3b18e512dba79e4c8300dd08aeb37f8e728b8dad

sha1sum43b71c903ff52b9885bd36f3866324ef60e27b9b

TREE OBJECT

COMMIT OBJECTheader

commit 185\x00

content tree 43b71c903ff52b9885bd36f3866324ef60e27b9b author insanehong <[email protected]> 1424843983 +0900 committer insanehong <[email protected]> 1424843983 +0900

add README.md file

sha1sume0d5a92d33f528147e62a87cd5589e9b4d78bb54

e0d5a92

commit

add README.md file

sizetree 43b71c90

43b71c90tree size

blob 3b18e512REAMDE.mdparent nullauthor insane

committer insane

blobhello world

3b18e512size

GIT OBJECTS

e0d5a92

commit

add README.md file

sizetree 43b71c90

43b71c90tree size

blob 3b18e512REAMDE.mdparent nullauthor insane

committer insane

blobhello world

3b18e512size

blobThe MIT License (MIT)

Copyright (c) ..

38c6bf23size

e0d5a92

commit

add LICENSE.md file

sizetree ffcdb59parent e0d5a92author insane

committer insane

ffcdb59tree size

blob

3b18e512

LICENSE.md

blob REAMDE.md

38c6bf23

Collaborative development with Git

새로운 기능 배포할게요!

bug fix 배포 안해요?

누가 내 코드 날려먹음? 누가 나 좀 돌려죠??!!

그냥 혼자 하고 싶다…

Q3. What is the BESTworkflow with git ?

A3. Nothing

• maint: maint tracks the commits that should go into the next "maintenance release”

• master: master tracks the commits that should go into the next release

• next: next is intended as a testing branch for topics being tested for stability for master.

• pu: pu is an integration branch for things that are not quite ready for inclusion yet

• topic: Make a side branch for every topic

- recommended workflows with Git in git Manual -

$ man gitworkflows

Git Champion!

"세상에서 가장 맛있는 음식은 이 세상 어머니 숫자와 동일하다."

- 영화 식객 中에서 -

Product

member culture

workflows

몇가지 Tip 을 알려드리는 것 뿐 정답이 아닙니다

Branch-Based WorkflowThere's only one rule: anything in the master branch is always deployable.

master

topic

Integration Branch

checkout

master

topic

Integration Branch

topic commit

master

topic

Integration Branch

bugfix

master

topic

Integration Branch

merge

delete

https://guides.github.com/introduction/flow/index.html

master

topic

github workflows

merge

deploy

remote/master

local/topic

topic Branch

checkout

remote/topic

remote/master

local/topic

topic Branch

topic commit

remote/topic

remote/master

local/topic

topic Branch

remote/topic

push topic branch

remote/master

local/topic

topic Branch

remote/topic

review fixed

remote/master

local/topic

topic Branch

remote/topic

push (force)

remote/master

local/topic

topic Branch

remote/topic

merge

팀원도 나도 모두 믿지 못하겠다면Fork Medel

Fork 는 GIT 이 아닌 GITHUB 의 기능

Central Remote Repository

Fork Repository from origin

핵심은Everybody fork the origin repository

clone

A

origin remote repository

A’s fork repository

fork

clone

B

B’s fork repository

fork

clone

C

C’s fork repository

fork

push

pull request / merge

pull(fetch) pull(fetch)

A B C

origin remote repositoryA’s fork repository

open source contribution workflow

bower/bower Pull Request

fork

local/bower

clonepush

insanehong/bower

fetch

commit

merge

팀원도 나도 모두 믿지 못하겠지만fork model 이 불편하다면?

Protected branches

protected branches

• Can't be force pushed

• Can't be deleted

• Can't have changes merged into them until required status checks pass

one Branch / one Topic• Context switching

• Dependency

• Revert

• Life Time

How to Branch management ?

Branch Naming

지운다고 지웠지만….

branch base 를 잘 선택해서$ git branch topic-name {target base}

rebase vs merge

엄마 vs 아빠

잘모르겠으면

그냥 merge 하세요.

하나의 feature 를 여러사람이 작업해야 하는 경우

with issue tracker

isolate discussion

Powerful commit messages Keywords

Closing issues via commit messages

• close• closes• closed• fix• fixes• fixed• resolve• resolves• resolved

Keywords for closing issues

https://help.github.com/articles/closing-issues-via-commit-messages/

GIT tip

$ git commit --allow-empty -m “initialized commit"

root commit

rebase interactive

git reflogdefaults to 90 days

GITHUBUNIVERSE 2015

Oct 1-2, 2015, CA

Every day 1,000 people create their first public pull request, 5,000 create

their first public repo

GEOGRAPHY TIMEZONE CULTURE

git 을 어려워 하는건 전세계가 여러분과 함께 합니다.

Q & A

Thanks

Git is a just tool! 본 자료는 15. 11.14 XECon 2015 에서 발표된 “Git Workflow with GitHub” 의 발표내용을 담고 있습니다.

본 자료는 크리에이티브 커먼즈 저작자표시-비영리-변경금지(CC BY-NC-ND) 3.0 Unported 라이선스에 따라 이용할 수 있습니다.

본 자료에 사용 된 이미지들은 Creative Common License 를 따르며 이미지 출처는 해당 이미지 하단에 기제 되어 있습니다.

twitter : @insanehongemail : [email protected]