I have a github account, but the company uses another account, and the company account requires configuring the user name and user email, so I set up global git config --global user.name and git config --global user.email , now I use the company account to pull and push normally, but every time I use my own account, it shows Permission denied (publickey). Then I need to manually add ssh-add ~/.ssh/id_myselfgithub every time, is there any How can I configure different accounts on the same computer?
When there are multiple git accounts, you need to configure ~/.ssh/config to distinguish them. Please search for the specific configuration
git configures your user through the configuration file
The global configuration user you mentioned is actually adding three lines to the ~/.gitconfig file
When you clone a git repository, there is a config file in the .git folder by default to record repository-level users
So your problem can be solved by adding your user information in /path/to/repository/.git/config, the format is the same as the result of global configuration.
Then git also provides a command line method to configure, as written above.
http://blog.styxzp.com/2016/0...
Detailed answer
You can refer to my previous article, I hope it will be a little inspiring /a/1190000008197936
Set the local
user
in the git project using your own account and it should be fineAfter generating the ssh public key, add it to your own git account configuration