5

Before anything else: I'm aware of the difference between SSH and HTTPS in this case. I usually create and manage my repos from IntelliJ or VS Code, but even when manually pushing to a remote from the terminal my credentials were never required, even though all my repositories use HTTPS. In fact, yesterday I was using a terminal window to push my commits to a given remote repository and it didn't ask me for anything. Today I needed to do a git push origin +HEAD to this very same repository, it asked for my username and password (PAT), and now every time I want to push anything it prompts me for the password.

I'm on Linux.

Alex Braga
  • 495
  • 1
  • 6
  • 19

1 Answers1

1

You should config cache credential for linux

git config --global credential.helper cache

The previous command will cache the credentials for some time (default 15 minutes)

If you want to store the credentials for ever

git config --global credential.helper store

For more information view this answer

Eng_Farghly
  • 1,987
  • 1
  • 23
  • 34
  • What really bugs me is the fact that I was able to do it seamlessly before and now that. It makes no sense. And I've never had the credential.helper set in my gitconfig. I know that because I have a backup copy of my gitconfig file and it only has some basic info. – Alex Braga Jul 29 '22 at 06:16
  • @AlexBraga I think you have a problem in credential that it store in Linux. Normally password store in credential after pushing the first time and you don't need to write again. – Eng_Farghly Jul 29 '22 at 06:24
  • Ok, I just found something funny. When I try to `git push` from a random terminal window or from the built in terminal on IntelliJ IDEA, it asks me for the credentials. HOWEVER, if I do it from the built in terminal on VS Code, it pushes right away without requesting anything. Is vscode passing its authorization token to the terminal or something? – Alex Braga Jul 29 '22 at 07:00
  • You should change setting for credential in IntelliJ IDEA view this answer https://stackoverflow.com/a/59565351/5661396 – Eng_Farghly Jul 29 '22 at 07:20
  • That was a good catch, thanks! It was, indeed, a matter of configuring my credentials inside gitconfig. The fact that I was able to `git push` without needing a password before is because I didn't realize I was always doing it from the integrated terminal in vscode and, like I thought, it passes its authorization to git commands, so I wasn't connecting the dots correctly in my original post – Alex Braga Jul 29 '22 at 08:50