LoginSignup
2
0

More than 1 year has passed since last update.

初めてのRailsチュートリアルに挑戦!第3章

Posted at

学習内容

  1. セットアップ
  2. 静的なページの作成と調整
  3. テスト実施
     *Red→Green→Refactorの実施
  4. タイトルの追加とテスト

学習時のエラー対応

最後にGitHubにプッシュする際に、以下のエラーが表示。

 $ git push origin master
To https://github.com/(ユーザー名)/sample_app.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/(ユーザー名)/sample_app.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

調べてみると、GitHubを直接編集したことにより、ローカルにその状態のGitが存在しないエラーのようだ。
(実際にGitHubで直接マージしていた)
そのため、git pull origin master でリモートリポジトリのGitをローカルに持ってくる。

git logで確認すると正しくpullできたようだ。

 $ git log
commit 97a26c3b4f597ff8f01a6420192e58a9b417304d (HEAD -> master)
commit 97a26c3b4f597ff8f01a6420192e58a9b417304d (HEAD -> master)
commit 97a26c3b4f597ff8f01a6420192e58a9b417304d (HEAD -> master)
Merge: 1da85c6 5b5c0c0
Author: (ユーザ名) <(登録アドレス)>
Date:   Sun Jul 3 05:44:25 2022 +0000

    Merge branch 'master' of https://github.com/(ユーザ名)/sample_app

commit 1da85c68599a006494730d2bdc155286f1275614 (static-pages)
Author: (ユーザ名) <(登録アドレス)>
Date:   Sun Jul 3 05:24:49 2022 +0000

    Finish static pages

commit 5b5c0c0b075937ab01a8302d7c520ab69f0c3f3d (origin/master)
Merge: 5e6780d 21811b3
Author:  (ユーザ名) <105146615+(ユーザ名)@users.noreply.github.com>
Date:   Sun Jul 3 10:51:20 2022 +0900

    Merge pull request #1 from  (ユーザ名)/static-pages
    
    Add a static pages controller

その後、git push origin masterで正しくGitHubにpushできた。

学習を終えて

プログラミングを進める中で、テスト駆動開発の重要性を学んだ。
また、テストをこまめに実施することで、エラー発生時の対応ポイントが絞られることがわかった。
今後の開発では定期的にGitHubへのプッシュとHerokuへのデプロイが求めらると実感した。

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