2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Git rebaseの使い方

Last updated at Posted at 2019-07-26

想定するシチュエーション

複数人で行う開発では、branchの運用が多いと思います。
特に、Git flowのルールに則った運用が多いのではないでしょうか。

Git flowでは、基本的に開発ブランチとして"develop"ブランチがあり、
そこから派生した"feature"ブランチがあります。
ある程度規模感があって、複数人で同時並行で開発するときには欠かせないのではないでしょうか。

それぞれがdevelopブランチからfeatureブランチを作り、開発を始めますが、
自身が開発している間にも他者がコミット・プッシュ〜プルリクエスト〜developブランチにマージをしています。お互いの開発部分に重なりがある場合、もちろんのこと他者の開発部分を取り込む必要があります。

そんなときにGit rebaseを使います。

  1. 自身の修正を退避します
git stash

2.developブランチに切り替える

git checkout develop/***

3.developブランチをリモートリポジトリと同期する

git pull

4.自身のfeatureブランチに切り替える

git checkout feature/***

5.自身のfeatureブランチにdevelopブランチの内容を取り込む

git rebase develop/***

6.退避していた修正を戻す

git stash pop

これでやってるんですが、皆さんはどのようにやってますか?
「これ違う!こうだよ!」ってアドバイス頂けたら嬉しいです。

2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?