210821 Hotfix branch - local master branch와 remote master branch의 차이

local master branch와 remote master branch의 차이

이번 포스팅에서는 실제 업무에서 master branch를 base로 hotfix branch를 끊어서 작업하면서 겪었던 문제에 대해서 작성해보려고 한다.

Hotfix branch에서의 작업

이번에 프로모션 페이지 컴포넌트 작업을 stage를 base branch로 두고 작업을 했었다. 이렇게 작업을 하게 되면, 개별 프로모션 페이지 컴포넌트 작업내용 뿐만 아니라 stage에서 여지까지 merge되었던 작업내용들까지 같이 master branch로 merge가 되기 때문에 master branch에서 개별 hotfix branch를 끊어서 작업을 해야했다.

그런데 local master branch에서 remote master branch를 pull해서 최신 상태로 업데이트를 한 뒤에 local master branch를 base로 새로운 hotfix branch를 끊어서 작업을 했는데, 여기서 문제가 발생했다.

local master branch와 remote master branch의 차이에 대한 이해

앞서 언급한 문제 상황에 대한 결론을 우선적으로 말하자면, local master branch는 현재 stage와 merged back된 상태이고, remote master branch는 stage에 merged back되지 않는 개별 branch 상태이다.
따라서 local master branch를 기반으로 hotfix branch를 끊게 되면, 작업 후에 remote master branch로 push를 하게 되면, merged back된 stage의 작업 내용들까지 같이 넘어가게 된다.

이러한 문제로 인해 hotfix branch는 반드시 origin/master branch를 base로 끊어서 작업을 해야한다.

origin/master를 base로 hotfix branch 작업

1
2
$ git checkout -b hotfix/promotion-page master (X)
$ git checkout -b hotfix/promotion-page origin/master (O)
Read more
an>
Sorting2
Spark2
Spring1
Stack1
Stack-frame4
String1
Study1
Suspense1
TDD5
TIL78
TTI1
TTV1
Tableau1
Terraform3
Tree-traversal2
Tuple1
Two-pointer-algorithm1
TypeScript15
Unit-Test2
Unit-test3
Unit-testing6
Vim1
Virtualenv2
Visualization2
Web-API1
Web-basic1
Web-browser1
Webpack1
Work-life-balance2
ZoneJS1
babel2
basic-term4
dummy-data2
eslint1
faker2
git1
hotfix-branch1
incomplete1
queue1
react-script1
repository1
self-development28
sorting1
this-binding1
webpack2