7
7

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.

herokuへデプロイしたあとにgit commit --amendしたらデプロイでエラー

Last updated at Posted at 2014-06-11

状況

しばしばこれをやってしまう、そそっかしい私です。

$ git commit -a -m 'version up'
$ git push heroku master

したあとにversion upが足りてないことに気付くw
足りてなかった分を追加し、commitする。

$ git commit -a --amend

そしてデプロイすると、

$ git push heroku master
Fetching repository, done.
To git@heroku.com:myapp.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@heroku.com:myapp.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.

non-fast-forwardだと怒られてしまいます。

解決法

herokuにはローカルが反映されていればいい、という立場でやってますので、

$ git push -f heroku master

-fを付けて強制的にpushしちゃいます。heroku側のブランチは消し去ります。
そういう立場じゃ無い人は、他の手段を取ってくださいm(_ _)m

参考

git - Cannot push to github - keeps saying need merge - Stack Overflow

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?