git remote 似乎根本不起作用

标签 git heroku

我正在关注 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 addcommit 步骤。根据需要修改您的应用程序,使用任何更改再次更新 git,然后 git push heroku master 进行部署。

从应用程序的根目录运行 more .git/config 以查看包含所有应用程序特定 git 设置的配置文件。这将列出您的远程仓库。

关于git remote 似乎根本不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3755529/

相关文章:

git - 两次提交或两个分支之间有多少行代码不同?

git 知道但(远程)svn 忽略

git - 如何在 Jenkins 执行 postman 测试?

Rails 2.3.5 拒绝 Heroku Push

ruby-on-rails - 如何在不使用 Heroku 工具的情况下使用 pg_dump?

git - 罕见的 Git 服务器错误 : "Refused pubkey" (but the key is tested valid)

Git: Squash 提交历史保持图形结构

python - ImportError: 仅当在 heroku 上部署 django 应用程序时才出现 win32

mysql - 在 Heroku 的 Cleardb 附加组件中更改默认架构名称

swift - 使用 heroku 部署完美的 swift