LoginSignup
10
13

More than 3 years have passed since last update.

git push heroku masterする際のエラー解消方法

Last updated at Posted at 2020-09-07

【概要】

1.結論

2.どのようなエラーか

3.なぜエラーが起きるのか

4.どのように解決するのか

1.結論

githubの左上メニューでCompare to Blanchを押してmasterにmargeする!

2.どのようなエラーか

ターミナル
%  git push heroku master
To https://git.heroku.com/*****.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://git.heroku.com/*****.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

このようなエラーが出てしまいました。
ローカルレポジトリ(master)からherokuへのmasterにpushしようとした際に拒否されてしまったエラーです。
hintが書いてありますが全く解決できずで、調べてもなかなか解決には至りませんでした。


3.なぜエラーが起きるのか

masterとローカルレポジトリにあるブランチが反映されていない状態になっており食違いがあったことが原因でした。

4.どのように解決するのか

なのでgithubの左上メニューでCompare to Blanchを押してmasterにmargeしたところ、エラーは無事に解決しました。

❶github desktopを開きますとMacですと左上にメニューバーが出てきます。そこで"Branch"を押下します。
スクリーンショット 2020-09-07 21.47.57.png

❷そしてCompare to Blanchを押します。
スクリーンショット 2020-09-07 21.48.06.png

❸そしてgithub desktopの画面に戻ってhistoryを見ていきます。

❹”1(1以上になっている)⬇︎”になっていると思うのでそれをmasterに統合します。
スクリーンショット 2020-09-07 21.48.35.png
写真では0⬇︎になっていますが、エラーが起きていた際は1⬇︎になっていました。その証拠に隣が1⬆︎になっています。
そうすることで再度、ターミナルで” git push heroku master”してあげるとうまく行きました。

そこで、いろいろと思い返しました。
Pay.jpでjavascriptに環境変数を記載して、herokuにpushする際にわざとプログラムを変更して読み込ませるようにしました。変更を加えた際に、ブランチを作ったような気がしました。やはり気のせいではなくブランチを作ってありました。


10
13
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
10
13