0

I wrote a powershell script to update multiple git repositories.

Everything is working fine, except for that on seemingly random times, the script suddenly asks for login credentials.

Does anyone know what could cause this?

Just to make sure, it does not always ask for login information. It works just fine, and updates all repos. It just randomly stops on one (random) repo, and asks for the login. After that it works fine again for a while.

I'm thinking about maybe building in a "sleep" in between repo updates, as the script might be requesting the updates to fast in a row, could this cause it?

Kind regards, Michael

Michaël
  • 357
  • 3
  • 9
  • are you using a PAT? – Toni Oct 07 '22 at 08:37
  • expiring password cache? – eftshift0 Oct 07 '22 at 08:43
  • I am using HTTPS access, with git and tortoise git installed. When accessing the repo through a HTTPS link, it asked me the login once. After that it remembered it. How can I check if I'm using a PAT? – Michaël Oct 07 '22 at 10:03
  • you are using username/password and so as eftshift0 mentioned the credentials cache did probably expire. I advise to generate a PAT and use this to authenticate. You can generate a PAT (Personal Access Token) in Bitbucket. to tell git to use a PAT add this parameter ```-c "http.extraHeader=Authorization: Bearer $token"``` where $token contains the PAT – Toni Oct 07 '22 at 10:57
  • I've added in the sleep I was thinking about, and with a sleep of 700ms the issue was gone completely. I ended up setting it to 1000ms by default, but made it a configurable parameter you can pass into the script. After this change, the issue is gone completely. – Michaël Oct 13 '22 at 06:22

1 Answers1

0

This issue is indeed cause by performing git calls to quick after another, by adding a delay in between git calls, the issue is gone totally.

So to anyone who wants to use a script to update a whole lot of repositories sequentially, sleep 1 second in between git calls, and you should not have this issue.

Michaël
  • 357
  • 3
  • 9