Git push error: “origin does not appear to be a git repository”

后端 未结 13 1244
醉话见心
醉话见心 2020-11-29 00:28

I am following the instructions given here to create a Git repository. All went well until the last line:

$ git push -u origin master  
相关标签:
13条回答
  • 2020-11-29 00:41

    May be you forgot to run "git --bare init" on the remote? That was my problem

    0 讨论(0)
  • 2020-11-29 00:43

    As it has already been mentioned in che's answer about adding the remote part, which I believe you are still missing.

    Regarding your edit for adding remote on your local USB drive. First of all you must have a 'bare repository' if you want your repository to be a shared repository i.e. to be able to push/pull/fetch/merge etc..

    To create a bare/shared repository, go to your desired location. In your case:

    $ cd /Volumes/500gb/   
    $ git init --bare myproject.git
    

    See here for more info on creating bare repository

    Once you have a bare repository set up in your desired location you can now add it to your working copy as a remote.

    $ git remote add origin /Volumes/500gb/myproject.git
    

    And now you can push your changes to your repository

    $ git push origin master
    
    0 讨论(0)
  • 2020-11-29 00:44

    To resolving this problem.I just create a new folder and put some new files.Then use these commond.

    * git add .
    * git commit 
    * git remote add master `your address`
    

    then it tells me to login in. To input your username and password. after that

    git pull 
    git push origin master
    

    finished you have pushed your code to your github

    0 讨论(0)
  • 2020-11-29 00:45

    Setting remote repository URL worked for me:

    git remote set-url origin https://github.com/path-to-repo/MyRepo.git

    0 讨论(0)
  • 2020-11-29 00:48

    I'll still share my short answer humbly, knowing that I'm super late to answer this question.

    Here's, a simple and clean explanation that solved my issue

    Also, since I was using the SSH key I used the following command:

    • $ git remote add origin git@github.com:{your-username}/{your-remote-repo-branch}

    for instance it would look like:

    • $ git remote add origin git@github.com:aniketrb-github/microservices.git

    If you are using the HTTPS URL, refer to the answer provided by @sunny-jim above.

    Do correct me if I'm wrong. Thanks.

    0 讨论(0)
  • 2020-11-29 00:52

    my case was a little different - unintentionally I have changed owner of git repository (project.git directory in my case), changing owner back to the git user helped

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