다른 사람들과 협업하기 위한 간단한 git flow를 적어본다.
중앙 원격 저장소(?)를 간단한게 github, github repo라고 부르겠다.
github에서 repo를 하나 생성한다.
github repo 웹페이지의 좌측 중앙에 있는 “Branch: master” 버튼을 클릭하여 “develop”을 입력하고 엔터를 치면 develop
branch가 생성된다.
Setting -> Branches로 들어가서 Default branch를 develop로 변경하고 Update 버튼을 클릭한다.
Default branch changed to develop
라는 메시지가 출력된다.
이 상태에서 github repo를 clone하면 develop branch 상태로 clone이된다.
> git status
On branch develop
Your branch is up-to-date with 'origin/develop'.
nothing to commit, working tree clean
local develop branch에서 feature branch를 생성한다.
feature branch의 이름은 feature/[branch-name]
과 같은 형식으로 생성한다.
> git checkout -b feature/npm-setting
git branch
라는 명령으로 상태를 확인해볼 수 있다.
> git branch
develop
* feature/npm-setting
코드를 작성/수정한다.
코드 수정이 완료되었다면 add/commit을 수행한다.
commit 후 feature branch를 githup repo에 push 한다.
> git push origin feature/[branch-name]
이렇게 하면 github repo의 새로운 feature/[branch-name]
branch가 생성된다.
push한 feature/[branch-name]
를 github repo의 develop branch에 merge하기 위해 pull request를 진행한다.
보통 github repo 웹페이지에 접속하여 Pull request
버튼을 클릭하여 처리한다.
merge까지 잘 되었다면 local에서 develop branch로 이동한다.
> git checkout develop
github repo의 merge된 데이터를 가져온다.
> git pull
local의 feature branch를 삭제한다.
> git branch -D feature/[branch-name]
github repo의 해당 feature branch도 삭제한다.
> git push origin :feature/[branch-name]