Git push requires username and password

前端 未结 24 2074
灰色年华
灰色年华 2020-11-22 04:14

I cloned a Git repository from my GitHub account to my PC.

I want to work with both my PC and laptop, but with one GitHub account.

When I try to push to or p

24条回答
  •  心在旅途
    2020-11-22 04:28

    Apart from changing to SSH you can also keep using HTTPS, if you don't mind to put your password in clear text. Put this in your ~/.netrc and it won't ask for your username/password (at least on Linux and Mac):

    machine github.com
           login 
           password 
    

    Addition (see VonC's second comment): on Windows the file name is %HOME%\_netrc.

    Also read VonC's first comment in case you want to encrypt.

    Another addition (see user137717's comment) which you can use if you have Git 1.7.10 or newer.

    Cache your GitHub password in Git using a credential helper:

    If you're cloning GitHub repositories using HTTPS, you can use a credential helper to tell Git to remember your GitHub username and password every time it talks to GitHub.

    This also works on Linux, Mac, and Windows.

提交回复
热议问题