0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

チーム開発でのブランチ運用の基本的な流れ(Git Flow風)

Posted at

これからチーム開発に参加するにあたって、GitHubの使い方が不安なのでまとめておこうと思います。
以下のような流れで作業するのが一般的です。

🔹 1. リポジトリをクローン

まずはチームの GitHub リポジトリ(=元リポジトリ)をローカルにクローンします:

git clone https://github.com/team/project.git
cd project

✅ この時点で maindevelop ブランチもローカルに取得されますが、main がデフォルトでチェックアウトされてることが多いです。

🔹 2. 作業ブランチ(feature)を作る前に develop を最新にする

git checkout develop <!-- developブランチに切り替える -->

git pull origin develop <!-- 最新のdevelopブランチをローカルに取りこむ -->

これで、最新の develop ブランチをローカルに取り込みます。

🔹 3. develop から作業用ブランチを切る

git checkout -b feature/awesome-feature

新しいブランチを作成して、自分のタスク(機能追加・修正など)を行います。

🔹 4. 開発してコミット & プッシュ

git add .
git commit -m "add awesome feature"
git push origin feature/awesome-feature

🔹 5. GitHub上で Pull Request(PR)を出す

チーム開発では、自分の feature/~ ブランチを develop にマージしてもらうために「Pull Request」を作成します。

✅ 対策:今いるブランチの確認

今いるブランチ名を確認すると安心です!

git branch

で、* がついてるブランチ名が「今のブランチ」です。

❌「クローンしただけ」=「最新の状態」ではないことがある(作業ブランチを作る前に最新の状態に!)
❌クローン直後は main がデフォルトになっていることが多い(今いるブランチをチェック!)

mainからブランチを切ると、後で develop にマージしようとした時に
「え?このコードないよ」みたいなことになるので要注意!!!

0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?