致命-“来源”似乎不是 git 存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/51279044/
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-09 05:18:54  来源:igfitidea点击:

fatal- 'origin' does not appear to be a git repository

gitgithub

提问by Kelly

I created a remote repo then create a local one locally:

我创建了一个远程仓库,然后在本地创建了一个本地仓库:

git init

then added the files i need using git addthen git commit -m "something"

然后添加的文件,我需要用git add那么git commit -m "something"

finally git push origin master

最后 git push origin master

I got this error fatal:

我得到了这个致命的错误:

'origin' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

should i like the remote and local in some command or something? and if so is it ok if i already added and commited or should i start over locally?

我应该喜欢某些命令中的远程和本地吗?如果是这样,如果我已经添加并提交了,还是应该在本地重新开始?

EDIT:

编辑:

Apparently i should add git remote add origin ssh://[email protected]:1234/myRepo.git but what should i replace that ssh with as in where can i find my version of what i should add.

显然我应该添加git remote add origin ssh://[email protected]:1234/myRepo.git 但是我应该用什么来替换那个 ssh,因为我在哪里可以找到我应该添加的版本。

Got this error :

得到这个错误:

! [rejected]        master -> master (fetch first)
error: failed to push some refs to 
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

回答by ElpieKay

When you run git clone <repo_url>to clone a repository, the default remote originis created automatically. If the repository is created by git init, there is no default remote, no origin. You need to set it up by yourself.

当您运行git clone <repo_url>克隆存储库时,origin会自动创建默认远程。如果存储库是由 创建的git init,则没有默认远程,没有origin. 你需要自己设置。

git remote add origin <repo_url>

repo_urlis the path to an existing remote repository which you want to exchange data with . If it's in the local disk, it could be file:///home/me/foo.gitor /home/me/foo.git. If it's hosted in Github, it could be https://github.com/me/foo.gitor ssh://[email protected]/me/foo.git.

repo_url是您要与之交换数据的现有远程存储库的路径。如果它在本地磁盘中,则可能是file:///home/me/foo.git/home/me/foo.git。如果它托管在 Github 中,则可能是https://github.com/me/foo.gitssh://[email protected]/me/foo.git

As to the 2nd error about "fetch first". You need to run git pull origin <branch>or git pull -r origin <branch>before a next push.

关于“先获取”的第二个错误。您需要运行git pull origin <branch>git pull -r origin <branch>在下一次推送之前。

回答by H? Kim Long S?n

try this

尝试这个

git remote add origin <https://github.com/"username"/"repository".git> 

then try to again

然后再试一次

git push -u origin master

回答by shaher11

git remote add origin <url>

then

然后

git push -u origin master

回答by Okpo

I had this same error message while trying to do a PR. On a critical look, I realized I was carrying out the Git workflow on a wrong directory.

我在尝试做 PR 时遇到了同样的错误消息。仔细一看,我意识到我在错误的目录上执行 Git 工作流程。

In my case, I simply went back a step to the right dir using **cd..** and then proceeded with no more error.

就我而言,我只是使用 **cd..** 返回到正确的目录,然后继续执行,不再出现错误。

回答by Ally Makongo

This happens because your config file contains master word instead of heroku git url. This might happen when you initialize git more than once.

发生这种情况是因为您的配置文件包含主词而不是 heroku git url。当您多次初始化 git 时,可能会发生这种情况。

  1. Edit the config file

    git config --e

  2. Then edit master word to heroku url e.g. https://git.heroku.com/project_name.git

  3. Save it wq!

  4. Then push update by git push heroku master

  1. 编辑配置文件

    混帐配置--e

  2. 然后将主词编辑为 heroku 网址,例如https://git.heroku.com/project_name.git

  3. 保存它wq!

  4. 然后通过 git push heroku master 推送更新

I hope this will help you!

我希望这能帮到您!