ブランチ戦略の使い分け
- GitHub Flow: 単純でデプロイ頻度が高いWebサービス向け。
mainブランチから機能ブランチ(feature/...)を生やし、Pull Request(PR)経由で即マージ。 - Git Flow: リリースサイクルが決まっているパッケージソフトウェアや大規模アプリ向け(
main,develop,feature,release,hotfixを厳格管理)。
競合(コンフリクト)の発生原因と安全な解消
複数の開発者が同じファイルの同じ行を変更した際に発生します。
Bash
# コンフリクト発生時の安全な解消手順
git fetch origin
git checkout feature/my-task
git rebase origin/main
# 競合ファイルをエディタで修正後
git add .
git rebase --continue
git push --force-with-lease origin feature/my-task
GitHub Actions による CI/CD パイプライン
コードがPRされた際に、自動でコードスタイルの検証(Linting)とテストを実行します。
YAML
# .github/workflows/ci.yml
name: Python CI
on:
pull_request:
branches: [ "main" ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff pytest pytest-cov
- name: Lint with Ruff
run: ruff check .
- name: Run Tests
run: pytest --cov=.

コメント