95
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

posted at

updated at

Herokuにpush時にdoes not appear to be a git repository出た時の対処

起きた問題

git push heroku masterを実行した時、以下のようなエラーが出た

$ git push heroku master

fatal: 'heroku' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

gitがリモートのリポジトリを参照出来ていなかった。

vimで.git/configを見てみる。

[remote "origin"]
  url = https://hoge@bitbucket.org/hoge/hoge.git
  fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
  remote = origin
  merge = refs/heads/master

remoteの参照先にherokuがなかった。

リモートにherokuを追加する。

vimで.git/configを直接編集してもいいし、コマンドで追加してもいい。

コマンドだとgit remote add heroku https://git.heroku.com/アプリケーション名.gitとする

上記コマンド実行後、再度.git/configを見てみると、remoteにherokuが追加されているのがわかる。

[remote "origin"]
  url = https://hoge@bitbucket.org/hoge/hoge.git
  fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
  remote = origin
  merge = refs/heads/master
[remote "heroku"]
  url = https://git.heroku.com/hoge.git
  fetch = +refs/heads/*:refs/remotes/heroku/*

上記が確認できたら、git push heroku masterでpushができるようになります。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
95
Help us understand the problem. What are the problem?