Context: after installing Sourcetree on a completely clean Windows 11 installation, when I log in to my GitHub account using HTTPS, after every interaction with the repository GitHub launches a popup with title “GitHub” subtitle “Select an account”, and which gives me a choice between “Personal Access Token” and my user account (in which I logged in previously).

Solution: Tell GCM to remember which account to use
Set a default account for a particular remote
git config --global credential.<URL>.username <USERNAME>
where is the remote URL and is the account you wish to have as the default. For example, for github.com and the user alice:
git config --global credential.https://github.com.username alice
Explanation
GCM (Git Credential Manager) can work with multiple identities. That's the reason why it all the time queries with which identity the next action should proceed.
In my case, I don't know the reason why in addition to my personal user account (the only one I have logged in with) it gives me the option of “Personal Access Token”.
I found the solution in this link, which in fact is the link provided in the same popup in “Why am I being asked to select an account?”.
I brought this solution here, because these horrible problems always occur when you are pressed for time and you know you will waste the next day solving something that should be very simple (like adding the “Remember this selection” option in the same popup), and that besides, we are lazy to read the suggested help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With