You are trying to push the repository code from your local into new repository in new Github account. You have already run the below command to set the remote origin path correctly-

$ git remote set-url origin https://github.com/testrepo/jenkins-terrform.git

when you run the git command to push the repository you receive the error-

$ git push origin master
remote: Permission to testrepo/jenkins-terrform.git denied to testuser.
fatal: unable to access 'https://github.com/testrepo/jenkins-terrform.git/': The requested URL returned error: 403

Solution:

This error is shown because Git have saved the username and password for your previous Github repository connection. It is trying to use the same to push this code to new repository.

On Windows you can find this user credentials and delete it so that it will show pop-up to provide new username and password.

go to Control panel –> User Accounts

Click “Manage your credentials”

click “windows credentials”

Under “generic credentials”, find github entry and remove it-

Remove the entry-

Try again ‘git push’ command, it will prompt for username and password.