1
0

More than 1 year has passed since last update.

【GitHub】ブランチ管理法【git-flow】

Last updated at Posted at 2022-01-07

0. はじめに

kazumakishimoto(@kazuma_dev)です!
git-flowを使ったブランチ管理法です。

0-1. 全体の流れ

1.git-flow準備
2.git-flow開発
3.git-flowリリース
Reference

0-2. 本記事の対象者

  • git-flowの使い方

0-3. 事前準備

  • リポジトリ名やブランチ名は一例のため、適当に変更してください

1. git-flow準備

1-1. Homebrewインストール

local
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

1-2. gitインストール

local
$ brew install git

1-3. git-flowインストール

local
$ brew install git-flow

1-4. ローカルリポジトリ作成

local
$ mkdir hogehoge
$ cd hogehoge

1-5. git-flow初期化

local
$ git flow init -d

1-6. リモートリポジトリ作成

kazumakishimoto_git_flow_test.png

1-7. リモートリポジトリ追加

local
$ git remote add origin https://github.com/kazumakishimoto/hogehoge.git
$ git push --all

2. git-flow開発

2-1. issue作成

feature_test · Issue #1 · kazumakishimoto_git_flow_test.png

2-2. featureブランチ共有

local
$ git flow feature start hogehoge#1
$ git flow feature publish hogehoge#1

2-3. リモートのdevelopブランチをpull

local
$ git pull origin develop

2-4. ローカル開発

local
$ git add -A .
$ git commit -m "hogehoge #1"
$ git push origin feature/hogehoge#1

2-5. GitHubでPR作成

kazumakishimoto_git_flow_test (1).png
Comparing develop...feature_test#1 · kazumakishimoto_git_flow_test.png

2-6. GitHubでPRマージ

test #1 by kazumakishimoto · Pull Request #2 · kazumakishimoto_git_flow_test.png
test2 #3 by kazumakishimoto · Pull Request #4 · kazumakishimoto_git_flow_test.png
test2 #3 by kazumakishimoto · Pull Request #4 · kazumakishimoto_git_flow_test (1).png

2-7. ローカルdevelopブランチでリモートdevelopブランチをpull

local
$ git checkout develop
$ git pull origin develop

2-8. マージ済みブランチ削除

local
$ git branch --merged|egrep -v '\*|develop|master'|xargs git branch -d
$ git remote prune origin

2-9. GitHubでclose issue

feature_test · Issue #1 · kazumakishimoto_git_flow_test (1).png

3. git-flowリリース

  • Heoku側の設定は割愛

3-1. releaseブランチ作成

local
$ git flow release start 1.x

3-2. releaseブランチ共有

local
$ git flow release publish 1.x

3-3. releaseブランチ終了

  • ⌘ + Sで保存
local
$ git flow release finish 1.x

Screenshot 2022-04-05 14.16.31.png

3-4. releaseブランチタグ付け

  • 追記後⌘ + Sで保存
MERGE_MSG
#
# Write a message for tag:
#   ver1.x
# Lines starting with '#' will be ignored.
 
+ Merge tag 'ver1.x' into develop

Screenshot 2022-04-05 14.17.01.png

3-5. GitHubにpush

local
$ git push --all

3-6. Herokuデプロイ

  • ※CI/CDツール使ってる方は下記不要(CircleCIでの自動デプロイ方法は下記記事参照)
local
$ git push heroku master
$ heroku run php artisan migrate:refresh --seed

Reference

  • Githubでissue管理して開発しよう - Qiita

  • GitHubのissueを活用した、個人アプリの開発手順を書いてみた - Qiita

  • Git-flowって何? - Qiita

  • git-flowを試す - Qiita

  • git-flow・GitHub Flow 実践要点メモ - Qiita

  • Gitでマージ済みブランチを一括削除 - Qiita

  • Git-flowをざっと整理してみた | DevelopersIO

  • git-flowの使い方 - 第3章 Github Flow/Git-Flowを使った運用 - [SMART]

  • git-flow cheatsheet

  • 【Laravel】CircleCI 2.1でPHPunit自動テスト × Heroku自動デプロイ

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0