我正在关注 railstutorial.org,当我到达“git push heroku master”部分时,出现以下错误:
fatal: Not a git repository (or any of the parent directories): .git
所以我做了一些谷歌搜索,发现一个常见的故障排除技巧是尝试“git remote -v”。问题是,每当我尝试这样做时,都会遇到与上述相同的错误。似乎无论我在“git remote”之后键入什么都会导致该错误。
我在这里做错了什么?!在撞到这堵砖墙之前,我一路顺风顺水。
最佳答案
您需要实际创建 git 存储库。简单地调用“heroku create”不会为你设置一个。对于现有文件夹,您需要输入它并运行如下命令:
git init
git add .
git commit -m 'Initial commit'
...然后添加 Remote (在此处填写 heroku info
中的 heroku git repo 名称):
git remote add heroku git@heroku.com:sushi.git
如果你正在启动一个新的应用程序并且当前目录中已经存在一个 git 存储库,heroku create
将为你添加 git 远程,你不需要运行最后一个命令.
mkdir new-app
cd new-app
git init
heroku create
之后,从该目录 rails new .
创建您的应用程序并运行上面的 git add
和 commit
步骤。根据需要修改您的应用程序,使用任何更改再次更新 git,然后 git push heroku master
进行部署。
从应用程序的根目录运行 more .git/config
以查看包含所有应用程序特定 git 设置的配置文件。这将列出您的远程仓库。
关于git remote 似乎根本不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3755529/