Skip to content

Commit 0ccad33

Browse files
docs(blog): 12차 배치 팁 포스트 5개 추가 (3개 언어)
1 parent 615e855 commit 0ccad33

15 files changed

Lines changed: 1112 additions & 0 deletions
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
layout: post
3+
title: "git worktree: Work on Multiple Branches Without Switching"
4+
date: 2026-03-14 09:00:00 +0900
5+
categories: [Development, Tips]
6+
tags: [Git, git-worktree, CLI, Version-Control]
7+
author: "Kevin Park"
8+
lang: en
9+
slug: git-worktree-multiple-branch-management
10+
permalink: /en/:year/:month/:day/:title/
11+
redirect_from:
12+
- /en/2026/03/14/git-worktree-multiple-branch-management-en/
13+
- /2026/03/14/git-worktree-multiple-branch-management-en/
14+
excerpt: "Use git worktree to open multiple branches in separate directories simultaneously. No more stash-checkout-pop cycles."
15+
---
16+
17+
## Problem
18+
19+
You're deep in a feature branch when a hotfix request comes in. Stash changes, checkout main, create a hotfix branch, fix the bug, push, then switch back and pop the stash. Repeat this several times a day and it gets old fast.
20+
21+
## Solution
22+
23+
`git worktree` lets you check out multiple branches into separate directories from a single repo.
24+
25+
```bash
26+
# Open main branch in a separate directory
27+
git worktree add ../project-main main
28+
29+
# Create a new branch with a worktree
30+
git worktree add ../project-hotfix -b hotfix/login-bug
31+
32+
# Open an existing branch
33+
git worktree add ../project-review feature/api-v2
34+
```
35+
36+
Now work in each directory independently. No branch switching needed.
37+
38+
```bash
39+
# Open multiple editor windows for simultaneous work
40+
code ../project-main # main branch
41+
code ../project-hotfix # hotfix branch
42+
code . # current feature branch
43+
```
44+
45+
Managing worktrees is straightforward:
46+
47+
```bash
48+
# List all worktrees
49+
git worktree list
50+
# /home/user/project abc1234 [feature/auth]
51+
# /home/user/project-main def5678 [main]
52+
# /home/user/project-hotfix ghi9012 [hotfix/login-bug]
53+
54+
# Remove a finished worktree
55+
git worktree remove ../project-hotfix
56+
57+
# Clean up manually deleted worktree directories
58+
git worktree prune
59+
```
60+
61+
Worktrees share `.git` data, so they use far less disk space than a full `git clone`. Commit history is shared across all worktrees.
62+
63+
## Key Points
64+
65+
- `git worktree add <path> <branch>` opens a branch in a separate directory
66+
- Work on multiple branches simultaneously without `checkout`
67+
- Shares `.git` data — much lighter than cloning
68+
- Clean up with `git worktree remove` when done
69+
- The same branch cannot be checked out in two worktrees at once
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
layout: post
3+
title: "git worktreeでブランチ切り替えなしに複数ブランチを同時作業する方法"
4+
date: 2026-03-14 09:00:00 +0900
5+
categories: [Development, Tips]
6+
tags: [Git, git-worktree, CLI, バージョン管理]
7+
author: "Kevin Park"
8+
lang: ja
9+
slug: git-worktree-multiple-branch-management
10+
permalink: /ja/:year/:month/:day/:title/
11+
redirect_from:
12+
- /ja/2026/03/14/git-worktree-multiple-branch-management-ja/
13+
- /2026/03/14/git-worktree-multiple-branch-management-ja/
14+
excerpt: "git worktreeで一つのリポジトリから複数のブランチを別ディレクトリで同時に開いて作業する方法を解説します。"
15+
---
16+
17+
## 問題
18+
19+
featureブランチで作業中に突然ホットフィックスの依頼が来ることがあります。`git stash`して`git checkout main`してホットフィックスブランチを作って...終わったら元のブランチに戻って`git stash pop`。これが一日に何回も繰り返されると、かなりストレスです。
20+
21+
## 解決方法
22+
23+
`git worktree`を使えば、一つのリポジトリから複数のブランチを別々のディレクトリに同時に開くことができます。
24+
25+
```bash
26+
# mainブランチを../project-mainディレクトリに開く
27+
git worktree add ../project-main main
28+
29+
# 新しいブランチを作りながらworktreeを作成
30+
git worktree add ../project-hotfix -b hotfix/login-bug
31+
32+
# 既存のブランチを開く
33+
git worktree add ../project-review feature/api-v2
34+
```
35+
36+
あとは各ディレクトリで独立して作業するだけです。ブランチの切り替えは不要です。
37+
38+
```bash
39+
# エディタで複数ウィンドウを開いて同時作業
40+
code ../project-main # mainブランチ
41+
code ../project-hotfix # ホットフィックスブランチ
42+
code . # 現在のfeatureブランチ
43+
```
44+
45+
worktreeの一覧確認と整理も簡単です。
46+
47+
```bash
48+
# 現在のworktree一覧
49+
git worktree list
50+
# /home/user/project abc1234 [feature/auth]
51+
# /home/user/project-main def5678 [main]
52+
# /home/user/project-hotfix ghi9012 [hotfix/login-bug]
53+
54+
# 作業が終わったworktreeを削除
55+
git worktree remove ../project-hotfix
56+
57+
# すでにディレクトリを手動削除した場合
58+
git worktree prune
59+
```
60+
61+
`.git`データを共有するため、`git clone`よりディスク使用量がはるかに少ないです。コミット履歴も当然共有されます。
62+
63+
## ポイント
64+
65+
- `git worktree add <パス> <ブランチ>`でブランチを別ディレクトリに開けます
66+
- ブランチ切り替え(`checkout`)なしで複数ブランチの同時作業が可能です
67+
- `.git`データを共有するのでcloneより軽量です
68+
- 作業が終わったら`git worktree remove`で整理します
69+
- 同じブランチを2つのworktreeで同時に開くことはできません
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
layout: post
3+
title: "git worktree로 브랜치 전환 없이 여러 브랜치 동시 작업하기"
4+
date: 2026-03-14 09:00:00 +0900
5+
categories: [Development, Tips]
6+
tags: [Git, git-worktree, CLI, 버전관리]
7+
author: "Kevin Park"
8+
lang: ko
9+
excerpt: "git worktree로 한 레포에서 여러 브랜치를 동시에 열어서 작업하는 방법. 브랜치 전환 스트레스가 사라진다."
10+
---
11+
12+
## 문제
13+
14+
feature 브랜치에서 작업 중인데 갑자기 핫픽스 요청이 들어왔다. `git stash` 하고 `git checkout main` 하고 핫픽스 브랜치 만들고... 끝나면 다시 원래 브랜치로 돌아와서 `git stash pop`. 이 과정이 하루에 몇 번씩 반복되면 진짜 짜증난다.
15+
16+
## 해결
17+
18+
`git worktree`를 쓰면 하나의 레포에서 여러 브랜치를 별도 디렉토리에 동시에 열 수 있다.
19+
20+
```bash
21+
# main 브랜치를 ../project-main 디렉토리에 열기
22+
git worktree add ../project-main main
23+
24+
# 새 브랜치를 만들면서 worktree 생성
25+
git worktree add ../project-hotfix -b hotfix/login-bug
26+
27+
# 기존 브랜치를 열기
28+
git worktree add ../project-review feature/api-v2
29+
```
30+
31+
이제 각 디렉토리에서 독립적으로 작업하면 된다. 브랜치 전환이 필요 없다.
32+
33+
```bash
34+
# 에디터에서 여러 창으로 동시 작업
35+
code ../project-main # main 브랜치
36+
code ../project-hotfix # 핫픽스 브랜치
37+
code . # 현재 feature 브랜치
38+
```
39+
40+
worktree 목록 확인과 정리도 간단하다.
41+
42+
```bash
43+
# 현재 worktree 목록
44+
git worktree list
45+
# /home/user/project abc1234 [feature/auth]
46+
# /home/user/project-main def5678 [main]
47+
# /home/user/project-hotfix ghi9012 [hotfix/login-bug]
48+
49+
# 작업 끝난 worktree 삭제
50+
git worktree remove ../project-hotfix
51+
52+
# 이미 디렉토리를 수동 삭제한 경우
53+
git worktree prune
54+
```
55+
56+
`.git` 데이터를 공유하기 때문에 `git clone`보다 디스크를 훨씬 적게 쓴다. 커밋 히스토리도 당연히 공유된다.
57+
58+
## 핵심 포인트
59+
60+
- `git worktree add <경로> <브랜치>`로 브랜치를 별도 디렉토리에 열 수 있다
61+
- 브랜치 전환(`checkout`) 없이 여러 브랜치를 동시에 작업 가능
62+
- `.git` 데이터를 공유하므로 clone보다 가볍다
63+
- 작업 끝나면 `git worktree remove`로 정리
64+
- 같은 브랜치를 두 개의 worktree에서 동시에 열 수는 없다
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
layout: post
3+
title: "Docker Compose Watch: Hot Reload for Containerized Development"
4+
date: 2026-03-15 09:00:00 +0900
5+
categories: [Development, Tips]
6+
tags: [Docker, docker-compose, hot-reload, Dev-Environment]
7+
author: "Kevin Park"
8+
lang: en
9+
slug: docker-compose-watch-hot-reload
10+
permalink: /en/:year/:month/:day/:title/
11+
redirect_from:
12+
- /en/2026/03/15/docker-compose-watch-hot-reload-en/
13+
- /2026/03/15/docker-compose-watch-hot-reload-en/
14+
excerpt: "Use docker compose watch to auto-sync code changes into containers. Cleaner than volume mounts."
15+
---
16+
17+
## Problem
18+
19+
Rebuilding with `docker compose up --build` after every code change is painful. Volume mounts work but introduce `node_modules` conflicts and cross-OS file watching issues.
20+
21+
## Solution
22+
23+
Docker Compose 2.22+ introduced `watch`. Add a `develop.watch` section to your `compose.yaml`:
24+
25+
```yaml
26+
services:
27+
web:
28+
build: .
29+
ports:
30+
- "3000:3000"
31+
develop:
32+
watch:
33+
# Source code changes → auto-sync to container
34+
- action: sync
35+
path: ./src
36+
target: /app/src
37+
38+
# package.json changes → rebuild image
39+
- action: rebuild
40+
path: ./package.json
41+
42+
# Config changes → sync and restart
43+
- action: sync+restart
44+
path: ./config
45+
target: /app/config
46+
```
47+
48+
Run it with:
49+
50+
```bash
51+
docker compose watch
52+
```
53+
54+
Three actions are available:
55+
56+
- **sync**: Copies files directly into the container. Best for source code changes.
57+
- **rebuild**: Rebuilds the image and replaces the container. Best for dependency changes.
58+
- **sync+restart**: Copies files then restarts the container. Best for config changes.
59+
60+
Exclude specific files with `ignore`:
61+
62+
```yaml
63+
- action: sync
64+
path: ./src
65+
target: /app/src
66+
ignore:
67+
- "**/*.test.ts"
68+
- "**/__snapshots__"
69+
```
70+
71+
## Key Points
72+
73+
- `docker compose watch` detects file changes and auto-syncs/rebuilds/restarts
74+
- No `node_modules` conflicts unlike volume mounts
75+
- Three actions (`sync`, `rebuild`, `sync+restart`) for different change types
76+
- `ignore` filters out unnecessary file changes
77+
- Requires Docker Compose 2.22+ (Docker Desktop 4.24+)
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
layout: post
3+
title: "Docker Compose Watchで開発環境のホットリロードを設定する方法"
4+
date: 2026-03-15 09:00:00 +0900
5+
categories: [Development, Tips]
6+
tags: [Docker, docker-compose, hot-reload, 開発環境]
7+
author: "Kevin Park"
8+
lang: ja
9+
slug: docker-compose-watch-hot-reload
10+
permalink: /ja/:year/:month/:day/:title/
11+
redirect_from:
12+
- /ja/2026/03/15/docker-compose-watch-hot-reload-ja/
13+
- /2026/03/15/docker-compose-watch-hot-reload-ja/
14+
excerpt: "docker compose watchでコード変更時に自動でコンテナに反映する方法。ボリュームマウントよりスマートです。"
15+
---
16+
17+
## 問題
18+
19+
Dockerで開発する際、コードを変更するたびに`docker compose up --build`を実行するのは非効率です。ボリュームマウント(`volumes`)を使う方法もありますが、`node_modules`の競合やOS間のファイル監視の問題が発生します。
20+
21+
## 解決方法
22+
23+
Docker Compose 2.22以降、`watch`機能が追加されました。`compose.yaml``develop.watch`セクションを追加します。
24+
25+
```yaml
26+
services:
27+
web:
28+
build: .
29+
ports:
30+
- "3000:3000"
31+
develop:
32+
watch:
33+
# ソースコード変更 → コンテナに自動同期
34+
- action: sync
35+
path: ./src
36+
target: /app/src
37+
38+
# package.json変更 → イメージリビルド
39+
- action: rebuild
40+
path: ./package.json
41+
42+
# 設定ファイル変更 → コンテナ再起動
43+
- action: sync+restart
44+
path: ./config
45+
target: /app/config
46+
```
47+
48+
実行方法はこちらです。
49+
50+
```bash
51+
docker compose watch
52+
```
53+
54+
3つのアクションがあります。
55+
56+
- **sync**: ファイルをコンテナに直接コピーします。ソースコードの変更に適しています
57+
- **rebuild**: イメージを再ビルドしてコンテナを置き換えます。依存関係の変更に適しています
58+
- **sync+restart**: ファイルをコピーしてからコンテナを再起動します。設定ファイルの変更に適しています
59+
60+
特定のファイルを除外したい場合は`ignore`を使います。
61+
62+
```yaml
63+
- action: sync
64+
path: ./src
65+
target: /app/src
66+
ignore:
67+
- "**/*.test.ts"
68+
- "**/__snapshots__"
69+
```
70+
71+
## ポイント
72+
73+
- `docker compose watch`はファイル変更を検知して自動で同期/リビルド/再起動します
74+
- ボリュームマウントと違い`node_modules`の競合がありません
75+
- `sync`、`rebuild`、`sync+restart`の3つのアクションで変更タイプに応じた対応が可能です
76+
- `ignore`で不要なファイル変更をフィルタリングできます
77+
- Docker Compose 2.22+が必要です(Docker Desktop 4.24+)

0 commit comments

Comments
 (0)