git remote 似乎根本不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3755529/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 04:35:37  来源:igfitidea点击:

git remote doesn't seem to be working at all

githeroku

提问by bjork24

I'm following along with the railstutorial.org, and when I get to the "git push heroku master" part, I get the following error:

我正在关注 railstutorial.org,当我到达“git push heroku master”部分时,出现以下错误:

fatal: Not a git repository (or any of the parent directories): .git

So I do some googling, and see a common troubleshooting trick is to try "git remote -v". The problem is, whenever I try that, I get the same error as above. It seems no matter what I type after "git remote" will result in that error.

所以我做了一些谷歌搜索,发现一个常见的故障排除技巧是尝试“git remote -v”。问题是,每当我尝试这样做时,都会遇到与上述相同的错误。似乎无论我在“git remote”之后输入什么都会导致该错误。

What am I doing wrong here?! I was cruising along so well until I hit this brick wall.

我在这里做错了什么?!我一直很好地巡航,直到我撞到这堵砖墙。

回答by Joost Schuur

You need to actually create the git repo. Simply calling 'heroku create' won't set one up for you. For an existing folder, you want enter it and run something like:

您需要实际创建 git 存储库。简单地调用 'heroku create' 不会为您设置一个。对于现有文件夹,您希望输入它并运行以下内容:

git init
git add .
git commit -m 'Initial commit'

...and then you add the remote (fill in your heroku git repo name from heroku infohere):

...然后添加遥控器(从heroku info此处填写您的 heroku git repo 名称):

git remote add heroku [email protected]:sushi.git

If you're starting a fresh app and a git repo already exists in the current dir, heroku createwill add the git remote for you, and you don't need to run that last command.

如果您正在启动一个新的应用程序并且当前目录中已经存在一个 git repo,heroku create将为您添加 git remote,并且您不需要运行最后一个命令。

mkdir new-app
cd new-app
git init
heroku create

After that, create your app from that dir rails new .and run the git addand commitsteps from above. Modify your app as desired, update git again with any changes, then git push heroku masterto deploy.

之后,从该目录创建您的应用程序rails new .并运行上面的git addcommit步骤。根据需要修改您的应用程序,使用任何更改再次更新 git,然后git push heroku master进行部署。

Run more .git/configfrom the app's root dir to see the config file with all of your app specific git settings. This will list your remote repos.

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

回答by milosmns

Ha! Just found out that you actually need to have a git repo created before the

哈!刚刚发现您实际上需要在之前创建一个 git repo

heroku apps:create app_name

call. Simply do

称呼。简单地做

git init
git add .
git commit -m "Initial Commit."

and then do the app creation command.

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

Hope this helps.

希望这可以帮助。

回答by Isaac Sekamatte

Just make sure you are calling the commands in the right folder, check and verify path in command line to make you are where you initialized git. That was my problem.

只需确保您在正确的文件夹中调用命令,检查并验证命令行中的路径以确保您在初始化 git 的位置。那是我的问题。

回答by rcoswe

I had a similar problem. The book is correct, but make sure you cdto the app directory first.

我有一个类似的问题。这本书是正确的,但请确保您cd先进入应用程序目录。

For example:

例如:

$ cd ~/rails_projects/first_app