LoginSignup
9
10

More than 5 years have passed since last update.

A successful Git branching modelのコマンド

Last updated at Posted at 2015-09-18

A successful Git branching modelとは

各ブランチについて

  • master
    リリース可能な状態を反映するブランチ。
    ブランチ名:master
    タグをつける。
  • develop
    開発用のメインブランチ。
    ブランチ名:develop
    masterブランチから作成する。
  • feature
    新機能を実装するためのブランチ。
    ブランチ名:master, develop, release-* , hotfix-* 以外
    developブランチから開発者のレポジトリのみに作成。
    修正完了後、developブランチへマージし、削除。
  • release
    リリースを準備するためのブランチ。
    ブランチ名:release-*
    developブランチから開発者のレポジトリのみに作成。
    修正完了後、developブランチとmasterブランチへマージし、削除。
  • hotfix
    バグを修正するためのブランチ。
    ブランチ名:hotfix-*
    masterブランチから開発者のレポジトリのみに作成。
    修正完了後、developブランチとmasterブランチへマージし、削除。

共有レポジトリ作成

$ cd xxx
$ mkdir project.git
$ cd project.git
$ git init --bare --shared

レポジトリ作成、共有レポジトリへpush

$ cd project
$ git init
$ git add .
$ git commit -m 'initial commit'
$ git remote add origin ssh://user@server:port/xxx/project.git
$ git push origin master

共有レポジトリからclone

$ cd xxx
$ git clone ssh://user@server:port/xxx/project.git

初期設定

$ git config user.name [あなたの名前]
$ git config user.email [あなたのメールアドレス]

developブランチ作成(masterブランチから)

$ git checkout -b develop master
$ git push origin develop

featureブランチ作成(developブランチから)

$ git checkout -b feature develop

featureブランチマージ(developブランチへ)

$ git checkout develop
$ git merge --no-ff feature
$ git push origin develop
$ git branch -d feature

releaseブランチ作成(developブランチから)

$ git checkout -b release develop

releaseブランチマージ(developブランチへ)

$ git checkout develop
$ git merge --no-ff release
$ git push origin develop

releaseブランチマージ(masterブランチへ)

$ git checkout master
$ git merge --no-ff release
$ git push origin master
$ git tag -a 1.0 -m 'version1.0 release'
$ git push --tags
$ git branch -d release

hotfixブランチ作成

$ git checkout -b hotfix master

hotfixブランチマージ(developブランチへ)

$ git checkout develop
$ git merge --no-ff hotfix
$ git push origin develop

hotfixブランチマージ(masterブランチへ)

$ git checkout master
$ git merge --no-ff hotfix
$ git push origin master
$ git tag -a 1.1 -m 'version1.1 release'
$ git push --tags
$ git branch -d hotfix
9
10
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
9
10