in Programming, Tips

Make git stop asking for your GitHub username and password over and over again

I created a new GitHub repository the other day, and was quick enough with copying its remote URL and adding it to my local Git repository:

git remote add origin

When I tried to push, however, I was asked for a username and password, although I have set up an SSH key on this machine, and set it up on GitHub ages ago. It turns out that I had added the wrong URL. Instead of an HTTPS URL, really, what you need is a Git one. GitHub provides a switch right on top, but if you are fast enough, you might as well not notice it:

GitHub switch

It is all about replacing http:// with

In case you have already added it to your local repo, changing it is just as easy. All you need is the git remote set-url command:

git remote set-url origin

That should do the job. The next time you push, Git won’t ask you about your username and password anymore.