6

When I do

git push

I get the command prompt like

Username for 'https://github.com':

then I enter my username manually like

Username for 'https://github.com': myusername

and then I hit Enter and I get prompt for my password

Password for 'https://myusername@github.com':

I want the username to be written automatically instead of manually having to type it all the time.

I tried doing it with xdotool but it didn't work out.

I have already done

git config --global user.name myusername
git config --global user.email myemail@gmail.com

but still it always asks for me to type manually

  • you know you can store credentials with git, right? – Diego Roccia Jul 18 '17 at 13:41
  • You should set up an SSH key on GitHub and use that instead. – Stephen Kitt Jul 18 '17 at 13:42
  • @DiegoRoccia yes, mentioned that as well in the question, but it doesn't help. – GypsyCosmonaut Jul 18 '17 at 13:45
  • You can use as git config credential.helper store described here: stackoverflow.com/questions/11403407/… In this case you do not store the password in clear text in the origin URL, but in a file in you profile. (Also not encrypted) – Oleg Rudenko Mar 15 at 17:43
4

Actually what you did there is setting up the author information, just for the commits. You didn't store the credentials. credentials can be stored in 2 ways:

  1. using the git credential functions: https://git-scm.com/docs/git-credential-store
  2. change the origin url to "https://username:password@github.com".
  3. a third alternative is to use an ssh key (as @StephenKitt said). For github configuration, you can find all needed information in GitHub help page
3

In Terminal, enter the following to enable credential memory:

$ git config --global credential.helper cache

You may update the default password cache timeout:

# This cache timeout is in seconds
$ git config --global credential.helper 'cache --timeout=3600' 

You may also use (but please use the single quotes, else double quotes may break for some characters):

$ git config --global user.name 'your user name'
$ git config --global user.password 'your password'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.