Git push: “fatal 'origin' does not appear to be a git repository - fatal Could not read from remote repository.”

后端 未结 9 1213
再見小時候
再見小時候 2020-11-28 18:04

I know similar questions have already been asked.

But, I believe my issue is due to a mistake I have previously made and therefore is different: let me explain.

相关标签:
9条回答
  • 2020-11-28 18:07

    A similar error appears while pulling the changes from the origin. If you are trying in Intellij from the menu options, the pull might not work directly.

    Go to terminal and type this command and this should work out: git pull origin master

    0 讨论(0)
  • 2020-11-28 18:07

    What fixed this for me was re-setting my origin url:

    git remote set-url origin https://github.com/username/example_repo.git

    And then I was able to successfully git push my project. I had to do this even though when I viewed my origins with git remote -v, that the urls were same as what I re-set it as.

    0 讨论(0)
  • 2020-11-28 18:11

    Sometimes you don't have a local REF for pushing that branch back to the origin.
    Try

    git push origin master:master
    

    This explicitly indicates which branch to push to (and from)

    0 讨论(0)
  • 2020-11-28 18:12

    As Matt Clark stated above

    However, origin might not be set, so skip the deleting step and simply attempting to add can clear this up.

    git remote add origin <"clone">
    

    Where "clone" is simply going into your GitHub repo and copying the "HTTPS clone URL" and pasting into GitBash

    0 讨论(0)
  • 2020-11-28 18:13

    if you add your remote repository by using git clone then follow the steps:-

    git clone <repo_url> then

    git init

    git add * *means add all files

    git commit -m 'your commit'

    git remote -v for check any branch run or not if not then nothing show then we add or fetch the repository. "fetch first". You need to run git pull origin <branch> or git pull -r origin <branch> before a next push.

    then

    git remote add origin <git url>
     git pull -r origin master
    git push -u origin master```
    
    0 讨论(0)
  • 2020-11-28 18:25

    I had the same issue. When I checked my config file I noticed that 'fetch = +refs/heads/:refs/remotes/origin/' was on the same line as 'url = Z:/GIT/REPOS/SEL.git' as shown:

    [core]
        repositoryformatversion = 0
        filemode = false
        bare = false
        logallrefupdates = true
        symlinks = false
        ignorecase = true
    [remote "origin"]
        url = Z:/GIT/REPOS/SEL.git     fetch = +refs/heads/*:refs/remotes/origin/*
    [branch "master"]
        remote = origin
        merge = refs/heads/master
    [gui]
        wmstate = normal
        geometry = 1109x563+32+32 216 255
    

    At first I did not think that this would have mattered but after seeing the post by Magere I moved the line and that fixed the problem:

    [core]
        repositoryformatversion = 0
        filemode = false
        bare = false
        logallrefupdates = true
        symlinks = false
        ignorecase = true
    [remote "origin"]
        url = Z:/GIT/REPOS/SEL.git
        fetch = +refs/heads/*:refs/remotes/origin/*
    [branch "master"]
        remote = origin
        merge = refs/heads/master
    [gui]
        wmstate = normal
        geometry = 1109x563+32+32 216 255
    
    0 讨论(0)
提交回复
热议问题