Git Flow
———————————————master : 소프트웨어 제품을 배포하는 용도로 쓰는 브랜치
| | ㄴ——— develop : 개발용 default 브랜치로, 이 브랜치를 기준으로 feature 브랜치를 따고, 각 feature를 합치는 브랜치
| | | ㄴ——feature: 단위 기능 개발용 브랜치
| | ㄴ————release: 다음배포를 위해 기능에 문제가 없는지 품질체크(QA) 용도의 브랜치
| ㄴ———hotfix: 배포가 되고 나서(master에 배포 코드가 합쳐진 후) 버그 발생 시 긴급 수정하는 브랜치
ㄴsupport: 버전 호환성을 위한 브랜치
✔ Local의 형태
(staging branch는 개인적인 취향상 추가한 거임)
✔ Basic Setting
The main branches
The different types of branches we may use are
∘ master (origin/master)
∘ develop (origin/develop)
∘ Feature branches
∘ Release branches
∘ Hotfix branches
Feature branches
∘ May branch off from: develop
∘ Must merge back into: develop
∘ Branch naming convention: anything except master, develop, release-*, or hotfix-*
1. create master branch
2. master base → create develop branch
3. case developer1 : feature /jini-v0.1 develop
3-1. case developer2 : feature /jini-0.2 develop
4. merge develop
✔ Git, Git Flow 설치
• Git을 설치하면 flow도 설치된다고 하니 생략해도 된다;;
( IntelliJ는 "git flow integration"라는 Plug-In이 있다고 한다. 깔아볼까 😉
$ brew install git
$ brew install git-flow-avh
• flow 초기화
$ git flow init -d // default
$ git flow init //입맛에 맞게 셋팅하고 싶으면 쓰자
branch 지정방법 1.
$ git checkout -b feature/jini-v0.1 develop
Switched to a new branch 'feature/jini-v0.1'
$ git checkout -b release/release-v0.1
Switched to a new branch 'release/release-0.1'
//이름 수정시
$ git branch -M release/release-v0.1 staging/staging-v0.1
//$ git checkout -b staging/staging-v0.1
//Switched to a new branch 'staging/staging-0.1' //jini's 취향
$ git checkout -b hotfix/hotfix-v0.1
Switched to a new branch 'hotfix/hotfix-0.1'
$ git checkout -b support/support-v0.1
Switched to a new branch 'support/support-0.1'
branch 지정방법 2.
$ git flow feature start [branch_Name]
$ git flow feature finish [branch_Name]
$ git flow release start [branch_Name]
$ git flow release finish [branch_Name]
$ git flow hotfix start [branch_Name]
$ git flow hotfix finish [branch_Name]
$ git flow support start [branch_Name]
$ git flow support finish [branch_Name]
• tag는 별도 지정해야 한다.
$ git tag -a 0.1 // tag 붙이기
$ git push --tag // tag 원격저장소 올리기 ( push 시에 tag는 제외 하고 파일들만 전송 됨 )
$ git tag -d 0.1 // tag 제거 하기
$ git push origin :0.1 // tag 원격저장소 지우기
✔ 작업의 시작
• 경로 feature/ develop 브랜치에서 작업할 브랜치 (jini-v0.2) 생성
$ git fetch feature/ develop
$ git checkout -b feature/jini-v0.2 --track develop
$ git commit -am "커밋 메시지 내용" //Staged 상태로 commit 생성
$ git status // 상태 확인
$ git add //파일 추적, staged상태
$ git status // 상태 확인
$ git push -u origin feature/jini-v0.2 develop //develop branch의 feature/jini-v0.2 변경 이력을 업데이트를 받은 후 origin(원격저장소명)
으로 push
//$ git remote //원격 저장소명 확인
$ git checkout -b feature/v0.1 develop
• jini-v0.1이나 jini-0.2로 작업
$ git checkout develop
Switched to branch 'develop'
$ git merge --no-ff feature/jini-v0.1 //The --no-ff flag causes the merge to always create a new commit object
Updating ea1b82a..05e9557
(Summary of changes)
$ git branch -d feature/jini-v0.1
Deleted branch feature/jini-v0.1 (was 05e9557).
$ git push origin develop
5. develop base → create release branch release
6. fixed a bug in the release branch
7. merge release branch → develop, master
Release branches
May branch off from: develop
Must merge back into: develop and master
Branch naming convention: release-*
$ git checkout -b release-0.1 develop
Switched to a new branch "release-0.1"
$ ./bump-version.sh 0.1 //modifiy user file
Files modified successfully, version bumped to 0.1.
$ git commit -a -m "Bumped version number to 0.1"
[release-0.1 74d9424] Bumped version number to 0.1
1 files changed, 1 insertions(+), 1 deletions(-)
8. master branch for create tags to write code versions
9. 배포
$ git checkout master
Switched to branch 'master'
$ git merge --no-ff release-0.1
Merge made by recursive.
(Summary of changes)
$ git tag -a 0.1
$ git checkout develop
Switched to branch 'develop'
$ git merge --no-ff release-0.1
Merge made by recursive.
(Summary of changes)
$ git branch -d release-0.1
Deleted branch release-0.1 (was ff452fe).
10. 만약 배포 나간 건에 대해서 긴급히 버그 처리해야 할 경우 master base 기반으로 hotfix 브랜치 생성
11. hotfix 브랜치를 master, develop에 머지
Hotfix branches
May branch off from:master
Must merge back into:develop and master
Branch naming convention:hotfix-*
$ git checkout -b hotfix-0.2.1 master
Switched to a new branch "hotfix-0.2.1"
$ ./bump-version.sh 0.2.1
Files modified successfully, version bumped to 0.2.1.
$ git commit -a -m "Bumped version number to 0.2.1"
[hotfix-0.2.1 41e61bb] Bumped version number to 0.2.1
1 files changed, 1 insertions(+), 1 deletions(-)
$ git commit -m "Fixed severe production problem"
[hotfix-0.2.1 abbe5d6] Fixed severe production problem
5 files changed, 32 insertions(+), 17 deletions(-)
$ git checkout master
Switched to branch 'master'
$ git merge --no-ff hotfix-0.2.1
Merge made by recursive.
(Summary of changes)
$ git tag -a 0.2.1
$ git checkout develop
Switched to branch 'develop'
$ git merge --no-ff hotfix-0.2.1
Merge made by recursive.
(Summary of changes)
$ git branch -d hotfix-0.2.1
Deleted branch hotfix-0.2.1 (was abbe5d6).
ps. 나중에 붙은 tag에 v가 빠진 건 안 비밀
참고
https://github.com/nvie/gitflow
GitHub - nvie/gitflow: Git extensions to provide high-level repository operations for Vincent Driessen's branching model.
Git extensions to provide high-level repository operations for Vincent Driessen's branching model. - GitHub - nvie/gitflow: Git extensions to provide high-level repository operations for Vincen...
github.com
https://nvie.com/posts/a-successful-git-branching-model/
A successful Git branching model
In this post I present a Git branching strategy for developing and releasing software as I’ve used it in many of my projects, and which has turned out to be very successful.
nvie.com
[Git] Commit tamplate file (0) | 2022.10.12 |
---|---|
[Git] Cherry-pick (0) | 2022.10.11 |
[Git] Merge 되돌리기 (0) | 2022.10.11 |
[Git] Flow 수정, 초기화 (0) | 2022.10.07 |
[Git] commit, push, merge (0) | 2022.10.07 |
댓글 영역