git remote似乎根本不起作用

bjo*_*k24 10 git heroku

我跟随railstutorial.org,当我到达"git push heroku master"部分时,我收到以下错误:

fatal: Not a git repository (or any of the parent directories): .git
Run Code Online (Sandbox Code Playgroud)

所以我做了一些谷歌搜索,看到一个常见的故障排除技巧是尝试"git remote -v".问题是,每当我尝试时,我都会得到与上面相同的错误.似乎无论我在"git remote"之后键入什么都会导致该错误.

我在这做错了什么?!我一直在巡航,直到我碰到这堵砖墙.

Joo*_*uur 31

你需要实际创建git repo.只需调用'heroku create'就不会为你设置一个.对于现有文件夹,您需要输入它并运行以下内容:

git init
git add .
git commit -m 'Initial commit'
Run Code Online (Sandbox Code Playgroud)

...然后你添加遥控器(从heroku info这里填写你的heroku git repo名称):

git remote add heroku git@heroku.com:sushi.git
Run Code Online (Sandbox Code Playgroud)

如果您正在启动一个全新的应用程序并且当前目录中已存在git repo,heroku create则会为您添加git远程,并且您无需运行该最后一个命令.

mkdir new-app
cd new-app
git init
heroku create
Run Code Online (Sandbox Code Playgroud)

在此之后,从DIR生成您的应用程序rails new .并运行git add,并commit从上面的步骤.根据需要修改您的应用程序,使用任何更改再次更新git,然后git push heroku master进行部署.

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

  • 我相信Uri忘了'cd'到他的repo的目录,并意外添加并将他的"我的文档"文件夹提交给他的回购. (7认同)

mil*_*mns 6

哈!刚发现你确实需要在之前创建一个git repo

heroku apps:create app_name
Run Code Online (Sandbox Code Playgroud)

呼叫.简单地做

git init
git add .
git commit -m "Initial Commit."
Run Code Online (Sandbox Code Playgroud)

然后执行应用程序创建命令.

希望这可以帮助.