Git Asks For Username Every Time I Push

Git asks for username every time I push

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

Git asks for username every time I push

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

Git keeps asking me to enter username and password

Just visit this page on GitHub and follow the instructions:

  • set credential helper first (explained clearly in the page)
    • for different types of credential helpers for different OSs' follow this link
  • then on the next prompt for password use your PAT instead (again explained clearly)

Git push asks username & password for HTTP repo origin

So, I have updated my origin remote from https to ssh and added a ssh public key to my github account after creating one which is well defined by github finally my problem solved and now I can push to my repo without any credential prompt by the terminal. Thank you Code-Apprentice.

Git asks password for wrong username whenever I git pull or push

First, you can view the URL used for the BitBucket repo by typing

git remote -v

This most likely will show that your colleague cloned has a remote that specifies your user name. The easiest way to fix this is to remove the user name from the url:

git remote set-url origin https://bitbucket.org/myself/my-repo.git

Now when they push/pull/fetch/etc, git will ask for both a user name and a url.

If your colleague doesn't want to type the user name each time, then they can instead do

git remote set-url origin https://colleague@bitbucket.org/myself/my-repo.git

If you are annoyed by always typing a username and password, I suggest setting up an SSH key and uploading the public key to BitBucket. The BitBucket docs explain how to do this. SSH is very convenient and provides secure access to your accounts.



Related Topics



Leave a reply



Submit