git worktree

ポイント

ディレクトリ構成はこのようになる

<repository name>/
 ├─ .claude/
 ├─ .devcontainer/
 ├─ .git/
 ├─ src/
 └─ .worktrees/
     ├─ feature-example/
     └─ bugfix-example/

事前作業

worktree.useRelativePathsを有効化

git config worktree.useRelativePaths true

# useRelativePaths = true があるはず
cat .git/config

.worktrees/ を.gitignoreにいれておく。

ワークツリーの作成

新規のブランチを切る場合

git worktree add -b feature/example .worktrees/feature-example origin/main

すでにあるブランチを使う場合

git worktree add .worktrees/feature-example feature/example

Claude Codeの起動

作成したワークツリーまで移動した後でClaude Codeを立ち上げる。

cd .worktrees/feature-example
claude

ワークツリーの削除

git worktree remove .worktrees/feature-example
Show Text to Share
git worktreeの利用

git worktree

https://www.tricrow.com/policies/use-worktree.html
この記事を書いた人
T.Nakamura
T.Nakamura
SRE | セキュリティ前提の設計・運用・監査対応(PCI DSS) | ドキュメント整備と仕組み化で開発・運用を整えます | AWS SAP / 日商簿記一級フォローはこちら

カテゴリ

タグ