作業用ディレクトリで開発する#
開発用ブランチを作成したら
git worktree
で作業スペースを作成してください。
# プロジェクトルートに移動する
$ cd haniwers
# ブランチ名を確認する
(main) $ git branch
+ 44-feat-threshold-scan-parallel
+ docs-discuss-datamodel
docs-for-developers
* main
updated-tags
# 作業スペースを作成する
# 書式: git worktree add 相対パス ブランチ名
(main) $ git worktree add ../worktrees/hnw-docs-dev docs-for-developers
# 作業スペースに移動する
(main) $ cd ../worktrees/hnw-docs-dev
(docs-for-developers) $ poetry install
worktreeで作成するディレクトリはプロジェクトの外(../worktrees/)に作成することが推奨されていますworktreeを使うと、ブランチごとに開発環境を隔離して安全に作業できます
作業スペースで開発する#
$ poetry install
$ poetry run pytest
$ poetry run ruff format
git add 編集したファイル名
git commit # Conventional Commitにしたがったコミットメッセージ
git merge origin/main # メインブランチの変更を取り込む
git push
作業スペースを削除する#
# メインブランチに移動する
(docs-for-developers) $ cd ../../haniwers
(main) $
# メインブランチを最新状態にする
(main) $ git fetch --prune
(main) $ git pull
# worktreeを確認する
(main) $ git worktree list
# worktreeを削除する
(main) $ git worktree remove ../worktrees/hnw-docs-dev
# ブランチを削除する
(main) $ git br -d docs-for-dev