gitSwitchAccount
起因是本地git存在多个账号,提交时显示登录的是lthero-g,我需要切换回lthero-big
1  | lthero@LtherodeMac-mini HiFi-Mark % git push  | 
These should reflect the lthero-big account. If not, update them:
1  | git config user.name "lthero-big"  | 
Update Remote URL to Include lthero-big Credentials Modify the repository’s remote URL to explicitly include the lthero-big username:
1  | git remote set-url origin https://lthero-big@github.com/lthero-big/HiFi-Mark.git  | 
This forces Git to authenticate as lthero-big. When you push, Git will prompt for the password or use a stored token.
Clear Cached Credentials Your system may have cached Lthero-g credentials. Clear them:
- 
On macOS
1
git credential-osxkeychain erase
Then enter:
1
2host=github.com
protocol=httpsPress Enter twice to clear the cached credentials.
 - 
Alternatively, open Keychain Access, search for github.com, and delete entries related to Lthero-g.
 
H Key (recommended for frequent use):
- 
Generate an SSH key for
lthero-big
if not already set up:
1
ssh-keygen -t ed25519 -C "email-associated-with-lthero-big"
Save it (e.g., ~/.ssh/id_ed25519_lthero_big).
 - 
Add the public key to GitHub under Settings > SSH and GPG keys. https://github.com/settings/keys
 - 
Update the remote URL to use SSH:
1
git remote set-url origin git@github.com:lthero-big/HiFi-Mark.git
 - 
Ensure the correct SSH key is used by configuring
~/.ssh/config
1
2
3
4Host github.com-lthero-big
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_lthero_bigUpdate the remote URL:
1
git remote set-url origin git@github.com-lthero-big:lthero-big/HiFi-Mark.git
 
最后,输入ssh -T git@github.com 来验证是否是lthero-big
这样操作下来,可以解决账号切换的问题,git credential-osxkeychain erase应该是关键步骤



