need github without username and password

后端 未结 2 1051
遥遥无期
遥遥无期 2020-12-07 04:14

I want to upload a project to the repository, but the problem is that, when I run the command:

$ git push -u origin master

It shows me some

相关标签:
2条回答
  • 2020-12-07 04:43

    I ran into a similar problem with github and solved it by configuring my git repo over SSH instead of HTTP.

    Step1: On the github.com page for your repo you will see three buttons HTTPS, SSH and Git Read Only. Click on "SSH" and copy the contents of the text field. Now there are a couple of ways you can change the configuration:

    Step 2a: By editing the config file manually:
    Open the .git folder of your repo and edit the config file. Look for [remote "origin"] and set the url config as follows:

    [remote "origin"]
    #The contents of the text field you copied in Step 1
    url = git@github.com:<username>/<projectname>.git
    

    Step 2b: With a git command:
    Just run the following command (replace username and projectname variables):

    git config remote.origin.url git@github.com:<username>/<projectname>.git
    

    Step3: You can view/confirm the changes with the following command. Look for "remote.origin.url" config:

    git config -l
    
    0 讨论(0)
  • 2020-12-07 04:44

    For an https address, git will use curl and will need a:

    $HOME/.netrc
    

    or (for Windows) a:

    %HOME%/_netrc
    

    (with %HOME% defined to any directory you want: HOME isn't defined by default)
    Its content:

    machine github.com
    login <your_github_login>
    password <your_github_password>
    

    See "Git - How to use .netrc file on windows to save user and password".
    Other parameters are detailed in "Syncing with github" (espacially if you are behind a firewall and need to specify a proxy).

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