Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git asks for username every time I push

Tags:

git

linux

github

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.

like image 208
RanRag Avatar asked Jul 09 '12 21:07

RanRag


People also ask

How do I get git to stop asking for my username?

To prevent Git from asking for your username and password, you can enter the login credentials in the URL as shown. The main drawback of this method that your username and password will be saved in the command in the Shell history file.

How do I stop git push from asking for username and password?

Issue the command git fetch/push/pull. You will not then be prompted for the password.

Why does git push ask for username?

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 compared with using SSH. It's easier to set up than SSH, and usually works through strict firewalls and proxies.


1 Answers

Edit (by @dk14 as suggested by moderators and comments)

WARNING: If you use credential.helper store from the answer, your password is going to be stored completely unencrypted ("as is") at ~/.git-credentials. Please consult the comments section below or the answers from the "Linked" section, especially if your employer has zero tolerance for security issues.

Even though accepted, it doesn't answer the actual OP's question about omitting a username only (not password). For the readers with that exact problem @grawity's answer might come in handy.


Original answer (by @Alexander Zhu):

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

like image 72
Alexander Zhugastrov Avatar answered Sep 28 '22 10:09

Alexander Zhugastrov