Git asks for username every time I push

Whenever I try to push into my repo git asks for both username & password .

I have no problem in re-entering my password each time but the problem is in entering username. I use https to clone my repository.

So, how can I configure git so that it doesn't asks for username on each git push .

I am new to linux but IIRC in windows git push only asks for password.


You can store your credentials using the following command

$ git config credential.helper store
$ git push http://example.com/repo.git
Username: <type your username>
Password: <type your password>

Also I suggest you to read
$ git help credentials


You can accomplish this in the .git/config file of your local repository. This file contains a section called 'remote' with an entry called 'url'. The 'url' entry should contains the https link of repository you're talking about.

When you prefix the host 'url' with your username, git shouldn't be asking for your username anymore. Here's an example:

url = https://username@repository-url.com

Permanently authenticating with Git repositories

Run following command to enable credential caching:

$ git config credential.helper store
$ git push https://github.com/repo.git

Username for 'https://github.com': <USERNAME>
Password for 'https://USERNAME@github.com': <PASSWORD>

Use should also specify caching expire

git config --global credential.helper 'cache --timeout 7200'

After enabling credential caching, it will be cached for 7200 seconds (2 hour) .


Read credentials Docs

$ git help credentials
链接地址: http://www.djcxy.com/p/27066.html

上一篇: Github“致命:远程起源已经存在”

下一篇: 每次我推送Git都要求输入用户名