この問題を解決するもう 1 つの方法は、heroku アプリに関連付けられている .git/config ファイルが何を行っているかを広く理解し、必要な調整を行うことです。
1.heroku.git/config
プロジェクトのルートから開きます。
マシン上でいくつかの heroku アカウントを使いこなしている場合は特に、git 構成ファイルは次のようになります。
git@heroku.{heroku.account}
git@heroku.com
ファイルの構成のためではなく、表示され~/.ssh/config
ます。への参照heroku-app-8396.git
は、heroku プロジェクト名と一致するように更新する必要があります。各 heroku アカウントには、~/.ssh/config
ファイル内のエントリが必要です。明らかに、この heroku プロジェクトが関連付けられている heroku アカウントが.git/config
ファイルに表示されます。
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = false
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git@heroku.heroku.account:heroku-app-8396.git
[remote "heroku"]
fetch = +refs/heads/*:refs/remotes/heroku/*
url = git@heroku.heroku.account:heroku-app-8396.git
[branch "master"]
remote = origin
merge = refs/heads/master
[heroku]
account = heroku.account
2. を実行するgit pull heroku master
と、すべてが正常に実行されているように見えます。
3. を実行するheroku logs
と、次のエラー メッセージが表示されます。
$ heroku ps
! No app specified.
! Run this command from an app folder or specify which app to use with --app APP.
なんで?
私が知る限り、heroku
コマンドは参照をどう処理するかを認識していないようです{heroku.account}
。これらの参照をcom
('accounts' heroku プラグインを使用していない場合のデフォルト値) に変更すると、heroku
コマンドは再び機能しますが、git
呼び出しで別の問題があることが示されます。
$ git pull heroku master
! Your key with fingerprint d6:1b:4c:48:8c:52:d4:d6:f8:32:aa:1a:e7:0e:a2:a1 is not authorized to access smooth-robot-8396.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
git
これを解決する 1 つの方法は、remote forとheroku
remote for を定義してheroku
から、使用するリモートを指定することです。
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = false
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git@heroku.heroku.account:heroku-app-8396.git
[remote "heroku"]
fetch = +refs/heads/*:refs/remotes/heroku/*
url = git@heroku.heroku.account:heroku-app-8396.git
[remote "heroku-app"]
fetch = +refs/heads/*:refs/remotes/heroku/*
url = git@heroku.com:heroku-app-8396.git
[branch "master"]
remote = origin
merge = refs/heads/master
[heroku]
remote = heroku-app
account = heroku.account
コンテンツをリモートにプッシュするときにリモートを明示的に指定するのが好きなので、heroku
リモートはそのためのものですが、この構成はデフォルト (例: ) を使用したプッシュ/プルにも対応していますgit push
。新しいリモート 'heroku-app' を作成し、URI に heroku アカウントを含まないリモートを使用するremote = heroku-app
ように指示するように追加します。heroku
git
これで、必要に応じてコマンドとコマンドを実行できますheroku
。