'git push' always needs password and username

Refer to :

https://help.github.com/articles/caching-your-github-password-in-git/

https://help.github.com/articles/why-is-git-always-asking-for-my-password/

If Git prompts you for a username and password every time you try to interact with GitHub, you're probably using the HTTPS clone URL for your repository.

Using an HTTPS remote URL has some advantages: it's easier to set up than SSH, and usually works through strict firewalls and proxies. However, it also prompts you to enter your GitHub credentials every time you pull or push a repository.

Caching your GitHub password in Git

Turn on the credential helper so that Git will save your password in memory for some time. By default, Git will cache your password for 15 minutes.

  1. In Terminal, enter the following:

    git config --global credential.helper cache
    # Set git to use the credential memory cache
    
  2. To change the default password cache timeout, enter the following:

    git config --global credential.helper 'cache --timeout=3600'
    # Set the cache to timeout after 1 hour (setting is in seconds)
    

猜你喜欢

转载自www.cnblogs.com/quinn-yann/p/9249250.html