The most simple and working solution i was able to find is removing the config file itself, git will generate it again so its fast and simple.
don't push till the very end.
rm ~/.gitconfig
Note: after doing this git will forget about your username and email so, run this command.
git will prompt this on your first fresh commit anyway, but don't forget to do this. the relation between you signed commit(via email) to account is very important.
git config --global --edit
Fill the info and you are good to go. Looks something like this.
# This is Git's per-user configuration file.
[user]
# Please adapt and uncomment the following lines:
name = yourusername
email = [email protected]
Now use cache to store the username and PAT(password) so you don't have to type it again and again on every push
git config --global credential.helper 'cache --timeout=3600' # 7776000 for 9 month
Try pushing now!
git config --global --unset credential.helper
# try pulling/pushing, enter username and PAT when prompted. Then,
git config --global credential.helper 'cache --timeout=3600' # 7776000 for 9 month
This is it.