Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 最初にデプロイしたPCとは違う端末で操作
// デプロイしようとしても公開鍵をHerokuに登録してないため怒られる
$ git push heroku master
Warning: Permanently added the RSA host key for IP address 'XX.XX.XX.XX' to the list of known hosts.
To git@heroku.com:APPNAME.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@heroku.com:APPNAME.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
// Herokuに公開鍵を登録する
// heroku用の鍵としてid_rsa_herokuという名前でつくる(名前は任意)
$ cd ~/.ssh
$ ssh-keygen -t rsa -C "[herokuアカウントのメールアドレス]"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ryu/.ssh/id_rsa):id_rsa_heroku
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
:
// heroku keys:addコマンドでherokuに鍵を追加する
$ heroku keys:add ~/.ssh/id_rsa_heroku.pub
// 公開鍵登録後、Herokuにデプロイしようとするが怒られる
$ git push heroku master
To git@heroku.com:APPNAME.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@heroku.com:APPNAME.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
// Herokuからpullする必要あり。pullしたあとは、正常にpushできる。
$ git pull heroku master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment