致命:'origin'似乎不是一个git存储库

xan*_*xan 75 git push github git-push

moodle在我的Github帐户上有一个存储库,我forked来自官方存储库.

然后我在我的本地机器上克隆它.它工作正常.我创建了几个分支(在master分支下).我做了几个提交,它工作正常.

当我这样做时,我不知道我是如何得到以下错误的: git push origin master

fatal: 'origin' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)

如何在不影响Github上的存储库的情况下解决错误?

我正在使用 Ubuntu 12.10

.git/config做的内容cat $(git rev-parse --show-toplevel)/.git/config给出了:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[branch "master"]
[branch "MOODLE_23_STABLE"]
[branch "MOODLE_24_STABLE"]
[remote "upstream"]
    url = git://git.moodle.org/moodle.git
    fetch = +refs/heads/*:refs/remotes/upstream/*
Run Code Online (Sandbox Code Playgroud)

Von*_*onC 101

$HOME/.gitconfig是你git 的全局配置.
三个级别配置文件.

 cat $(git rev-parse --show-toplevel)/.git/config
Run Code Online (Sandbox Code Playgroud)

(提及变成真正的)是你的本地配置,本地已克隆回购.

你也可以在你的回购中输入:

git remote -v
Run Code Online (Sandbox Code Playgroud)

并查看其中是否列出了任何名为"origin"的远程.

如果没有,如果缺少该远程(在克隆存储库时默认创建),则可以再次添加:

git remote add origin url/to/your/fork
Run Code Online (Sandbox Code Playgroud)

OP提到:

git remote -v了给:

upstream git://git.moodle.org/moodle.git (fetch) 
upstream git://git.moodle.org/moodle.git (push)
Run Code Online (Sandbox Code Playgroud)

所以' origin'缺失:对你的 fork 的引用.
请参阅" github 之间有什么区别originupstream "

在此输入图像描述


Ani*_*kur 16

当我在GitHub上重命名我的存储库时,我遇到了同样的问题.我试图推动我得到了错误

fatal: 'origin' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)

我不得不使用更改URL

git remote set-url origin ssh://git@github.com/username/newRepoName.git
Run Code Online (Sandbox Code Playgroud)

在此之后所有命令开始正常工作.您可以使用以检查更改

git remote -v
Run Code Online (Sandbox Code Playgroud)

在我成功更改后的情况下,它在URL中显示了正确的重命名repo

[aniket@alok Android]$ git remote -v
origin  ssh://git@github.com/aniket91/TicTacToe.git (fetch)
origin  ssh://git@github.com/aniket91/TicTacToe.git (push)
Run Code Online (Sandbox Code Playgroud)


siv*_*ivi 7

你尝试拉出的另一个分支可能不同步; 所以在添加和删除远程尝试之前(如果你试图从主人那里拉)

git pull origin master
Run Code Online (Sandbox Code Playgroud)

对我来说,简单的调用解决了这些错误消息:

  • 致命:'master'似乎不是一个git存储库
  • 致命:无法从远程存储库读取.


小智 7

我遇到了同样的问题并通过检查解决了

git remote -v

git init the repo URL

git remote add origin the repo URL

git push -f origin master
Run Code Online (Sandbox Code Playgroud)


zdr*_*kin 5

尝试先创建远程源,可能因为您更改了远程存储库的名称而丢失

git 远程添加源 URL_TO_YOUR_REPO