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

后端 未结 9 1214
再見小時候
再見小時候 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:26

    First, check that your origin is set by running

    git remote -v
    

    This should show you all of the push / fetch remotes for the project.

    If this returns with no output, skip to last code block.

    Verify remote name / address

    If this returns showing that you have remotes set, check that the name of the remote matches the remote you are using in your commands.

    $git remote -v
    myOrigin ssh://git@example.com:1234/myRepo.git (fetch)
    myOrigin ssh://git@example.com:1234/myRepo.git (push)
    
    # this will fail because `origin` is not set
    $git push origin master
    
    # you need to use
    $git push myOrigin master
    

    If you want to rename the remote or change the remote's URL, you'll want to first remove the old remote, and then add the correct one.

    Remove the old remote

    $git remote remove myOrigin
    

    Add missing remote

    You can then add in the proper remote using

    $git remote add origin ssh://git@example.com:1234/myRepo.git
    
    # this will now work as expected
    $git push origin master
    
    0 讨论(0)
  • 2020-11-28 18:28

    It works for me.

    git remote add origin https://github.com/repo.git
    git push origin master
    

    add the repository URL to the origin in the local working directory

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

    Make sure the config file at .git is correct...Check URL & Make sure your using the correct protocol for your keys ...ProjectWorkspace/.git/config

      ~Wrong url for git@bitbucket
    [core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
    [remote "origin"]
        url = gitbucket.org:Prezyack/project-one-hello.git
        fetch = +refs/heads/*:refs/remotes/origin/*
    
     ~Wrong URL for SSH...
    [core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
        precomposeunicode = true
    [remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = https://emmap1@bitbucket.org/emmap1/bitbucketspacestation.git
    [branch "master"]
        remote = origin
        merge = refs/heads/master
    

    We are looking at the URL... e.g: For bitbucket, expect git@bitbucket.org....If its gitbucket.org. make the necessary changes.. SAVE Try pushing again.

    0 讨论(0)
提交回复
热议问题