Git push asks username & password for HTTP repo origin

Viewed 588

I am working on a project of mine and I got the codes uploaded in github. I started working in this project from Win10 os and currently I'm working in Arch linux. In windows it didn't use to ask me for any password but it does now.

I've never pushed from my linux before. Today when I tried to push the terminal and VB code both are asking for my github username and password.

I kept a backup of this project at my usb hard drive and currently I pasted it in my linux ssd. What I'm saying is I didn't clone it from the repo. As far as my global username & user email are concerned both are accurate. I'm not using any SSH so when I type git remote -v in my terminal it shows https link as the origin for both fetch and push.

Why is it asking for my username and password? Is it secure to provide my password? In case if I provide my credentials then do I have to provide it every time I push? How to fix this?

I have searched stackoverflow for solution but the other questions that I have found doesn't match my criteria cause in windows it was working fine without asking any credentials.

3 Answers

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.

While in general, providing a username and password to git is secure, GitHub no longer allows authentication with username and password. Instead, you need to either use ssh or generate a personal access token.

See source for details.

Why people are editing my posts I don't understand. I'm trying to post a solution of the problem that I have faced previously. Then why people are editing my posts? I just want to put a proper solution for the future so that people get benefited from this. However, the solution of the problem is you have to do ssh push then it won't prompt for username & password anymore. That's all. Now please do not edit my post. I am not even sure how you are allowed to do that!

Related