Git/GitHub can't push to master

前端 未结 11 1818
抹茶落季
抹茶落季 2020-12-07 07:09

I am new to Git/GitHub and ran into an issue. I created a test project and added it to the local repository. Now I am trying to add files/project to the remote repository.

11条回答
  •  暖寄归人
    2020-12-07 07:56

    This error occurs when you clone a repo using a call like:

    git clone git://github.com/....git
    

    This essentially sets you up as a pull-only user, who can't push up changes.

    I fixed this by opening my repo's .git/config file and changing the line:

    [remote "origin"]
        url = git://github.com/myusername/myrepo.git
    

    to:

    [remote "origin"]
        url = ssh+git://git@github.com/myusername/myrepo.git
    

    This ssh+git protocol with the git user is the authentication mechanism preferred by Github.

    The other answers mentioned here technically work, but they all seem to bypass ssh, requiring you to manually enter a password, which you probably don't want.

提交回复
热议问题