Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
112 views
in DevOps and Agile by (29.3k points)

I am using Git Bash on Windows 7. We are using GitHub as our repository origin.

Every time I push or pull I have to provide user and password credentials. I know that my SSH keys are set up correctly, otherwise, I would not be able to access the repository. (That is, once I enter my credentials the push/pull works correctly.)

I have entered

git config --global user.name myusername

git config --global user.email myemail

git config --global github.user myusername

git config --global github.token mytoken

But I am being asked for credentials each and every time I push/pull.

3 Answers

+1 vote
by (50.2k points)

For this question, if you want to login without giving credentials on each and every pull you could use the ssh link instead of https url. https url is used then it will ask for the credentials when you push/pull.

To check the url you can run:

git remote show origin 

or 

git config -e

or 

check the file .git/config. if there are any changes regarding url changes it then you can able to push or pull without credentials.

If you wish, you can learn more about commands on Git commands.

0 votes
by (37.3k points)

Making sure your Git is using SSH rather than HTTPS is the first step. This guarantees that you won't be prompted for your password and login each time.

How to do it is as follows:

1. Verify the remote URL you are using:

git remote -v

2. If it starts with `https://`, change it to use SSH:

git remote set-url origin [email protected]:yourusername/your-repository.git

With this modification, Git will now authenticate using your SSH key rather than requesting credentials.

0 votes
by (1.8k points)

Git is more likely to be using HTTPS for the URL of your repository by default which, explains why you are always asked for your credentials. When the legitimate SSH keys are established, it is possible to overcome this problem by simply changing the repository's URL from HTTPS to SSH.

Here’s how to change the remote url to SSH in the Git Bash:

Find out the Current Remote URL:


git remote -v


In the cases when the URLs start with https:, it points that Git is using the HTTPS and hence it will ask for credentials every time.

Change the remote url back to SSH: Change the remote url to ssh by stating the below command:

git remote set-url origin [email protected]:yourusername/yourrepository.git


Make sure to substitute yourusername and yourrepository with your actual github username and repository name.

Check the Connection To The SSH: To ensure that your SSH connection is working fine, you may use the following command:

ssh -T [email protected]

This command should respond with a message that GitHub access via SSH is possible.

Execute Push or Pull with Out Asking for Your Password Prompt: Now, please try running a git pull or git push command. Since the connection now uses SSH, it should no longer ask for your username and password.

In case the issues persist and you will also want to check that your SSH key is added correctly to your GitHub account and also it is loaded into your SSH agent. Please also tell me if you need support for those steps too.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...