Pushing to git with Personal Access Token is asking for password

Viewed 342

I have a shell script file which will push the files to empty git repo.

git init
git add .
git commit -m "first commit"
git remote add origin https://<my-personal-access-token>@github.com/<organization-name>/<repo-name>.git 
git push -u origin master

This was pushing files to repo without asking for password, but surprisingly now it is asking for password too.

enter image description here

Why is it asking for password even though I used personal access token? What is going wrong here?

Even if I input correct password manually, it says as below :

enter image description here

1 Answers

You can try below line in your code for git remote step by adding username to it:

git remote add origin https://username:<my-personal-access-token>@github.com/<organization-name>/<repo-name>.git
Related