Unable to Git-push master to Github - 'origin' does not appear to be a git repository / permission denied

前端 未结 9 1177
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 15:21

This question is related to my problem in understanding rebase, branch and merge, and to the problem

How can you commit to your github account as you

9条回答
  •  孤城傲影
    2020-11-22 15:57

    What does

    $ git config --get-regexp '^(remote|branch)\.'
    

    returns (executed within your git repository) ?

    Origin is just a default naming convention for referring to a remote Git repository.

    If it does not refer to GitHub (but rather a path to your teammate repository, path which may no longer be valid or available), just add another origin, like in this Bloggitation entry

    $ git remote add origin2 git@github.com:myLogin/myProject.git
    $ git push origin2 master
    

    (I would actually use the name 'github' rather than 'origin' or 'origin2')


    Permission denied (publickey).
    fatal: The remote end hung up unexpectedly

    Check if your gitHub identity is correctly declared in your local Git repository, as mentioned in the GitHub Help guide. (both user.name and github.name -- and github.token)

    Then, stonean blog suggests (as does Marcio Garcia):

    $ cd ~/.ssh
    $ ssh-add id_rsa
    

    Aral Balkan adds: create a config file

    The solution was to create a config file under ~/.ssh/ as outlined at the bottom of the OS X section of this page.

    Here's the file I added, as per the instructions on the page, and my pushes started working again:

    Host github.com
    User git
    Port 22
    Hostname github.com
    IdentityFile ~/.ssh/id_rsa
    TCPKeepAlive yes
    IdentitiesOnly yes
    

    You can also post the result of

    ssh -v git@github.com
    

    to have more information as to why GitHub ssh connection rejects you.

    Check also you did enter correctly your public key (it needs to end with '==').
    Do not paste your private key, but your public one. A public key would look something like:

    ssh-rsa AAAAB3== tek...@gmail.com 
    

    (Note: did you use a passphrase for your ssh keys ? It would be easier without a passphrase)

    Check also the url used when pushing (git@github.com/..., not git://github.com/...)

    Check that you do have a SSH Agent to use and cache your key.

    Try this:

     $ ssh -i path/to/public/key git@github.com
    

    If that works, then it means your key is not being sent to GitHub by your ssh client.

提交回复
热议问题