Git asking for username and password


Git push asking for username and password

I recently had a project setup on my home system but I had already created the repo on Github (dont ask me why, I’m just learning). I ran git init and added the files to the staging area and commited the new image folder I had added to the project, however when i tried to run git push -u origin main. I was asked for my username and password when I didn’t set a password. After a bit of research I discovered that I had ran git git remote add origin and that is why I was being asked for a password and username.

I fixed the issue by running git remote set-url origin, which allowed me to push the changes. What I would like to know is why this happens (I think its because of the ssh key I added), is that right, and if so is the http option mainly used to link images and referance in scripts etc?

>Solution :

Basically, when you are interacting with github server via URL HTTPS git use the HTTP method to communicate to the server, but HTTP is insecure so git will require your credentials to authenticate the user with the remote server before you can do anything. But this method of authentication was deprecated some time ago, as the first comment said, it is a better choise to authenticate with SSH because this improves the security and integration of the data your sending to the remote.

You can read more about it here

Leave a ReplyCancel reply