Unable to access https means: this has nothing to do with SSH (and switching to SSH, while possible, does not explain the original issue)
This has to do with credential caching, meaning Git will be default provide the credentials (GitHub account and password) of the old account while you are trying to push to the new account.
See if you have a credential helper that would have cached your (old account) credentials (username/password) used to authentication you.
git config credential.helper
On Mac, as commented by Arpit J, just goto/open your keychain access->search for github.com related file->and edit credentials there.
See "Updating credentials from the OSX Keychain"
On Windows (And, in 2021, possibly Linux or even Mac), that would be the Windows Credential Managers GCMC: Git Credential Manager Core.
Open the Windows Credential Store, and see if the first user is registered there: delete that entry, and you will be able to authenticate with the second user.
(Here is an example for BitBucket)
In command-line (see git credential
), for a manager core credential helper:
Get the old password:
printf "protocol=https
host=github.com
username=<me>" |
git credential-manager-core get
# output:
protocol=https
host=github.com
username=<me>
password=<oldpassword>
Remove the old password:
printf "protocol=https
host=github.com
username=<me>" |
git credential-manager-core erase
(Replace <me>
by your GitHub user account name)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…