LoginSignup
1
1

More than 5 years have passed since last update.

【GitHub】Pull Request をする際に作業毎にRequestを出したい

Last updated at Posted at 2019-01-23

やりたいこと

Pull Requestをする時に、作業ごとにRequestを出したい。
例)
ログインページと新規登録ページを作り、別々にPull Requestを出したい。。
だけどRequestを二つ出してしまうと、なぜかRequestが一つのところにまとまってしまう。

原因

Branchを一つにしてしまっているから。

解決方法

Branchを作業毎に分ける。

やり方

git branchで新たにbranchを作成する。

$ git branch login_button

git checkout ブランチ名で作成したブランチに移動

$ git checkout login_button

※上記はgit checkout -b login_buttonとすることでブランチを作成しその後移動させることができる。

git statusで変えたいファイルを確認する。

        modified:   app/views/sessions/new.html.erb
        modified:   app/views/users/new.html.erb

git add ファイル名でstagingするファイルを指定

まずはログインページ(sessions/new)を指定する。

$ git add app/views/sessions/new.html.erb

git statusで現状を確認すると一つのファイルだけstagingされている

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   app/views/sessions/new.html.erb

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   app/views/users/new.html.erb

⑤コミット名を決めてgitにコミット

$ git commit -m 'modified login button'

git push origin login_buttonとしてリモートリポジトリにpush

$ git push origin login_button

この時git push origin login_button:自分のつけたい名前とすることでリモートリポジトリにpushすると、リモートリポジトリには自分のつけたい名前が反映される。

この後GitHub上でPull Requestをすると下のようになる。

Screen Shot 2019-01-23 at 16.48.20.png

⑦branchの名前をsignin_buttonとして①~⑥を繰り返す。

⑧Pull Requestが作業毎に出来る

Screen Shot 2019-01-23 at 16.57.12.png

結論

Pull Requestを出すときはBranchを分けることによって、作業毎にRequestを出すことができる。

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