1
3

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 3 years have passed since last update.

【解決方法】[rejected] master -> master (non-fast-forward) エラーで pushできない 【コンフリクト】

Last updated at Posted at 2021-01-03

#問題
ターミナルにてGitHub DesktopのmasterブランチをHerokuにpushしようとしたところ下記エラーが生じ、pushができない。

 % 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.

#原因
Heroku上の今までpushしたcommit履歴内容と、pushしたいGitHub Desktopのmasterブランチのcommit内容でコンフリクトしたため、エラーが生じた。

#解決
以下の記述でpushする。

 % git push -f heroku master

このpushでは、GitHub Desktopのmasterブランチのcommit内容で、Herokuの今までpushしたcommit履歴内容を強制的に上書きしてpushする。

コンフリクトの解消法の一つとしてぜひご活用ください。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?