I first deleted all credentials related to git in the credential manager in Windows, changed my user.name and user.email to another user in a repo and then push to a remote. Git then asked me to login via browser. I clicked the login button and the browser tab that showed up told me the authentication succeeded right away without asking me to enter the password of the new user. And when I check the commits history on Github, it showed the commit was made by the new user(the user that I changed my user.name to), but that user has never logged in on my computer. How is this possible? Is it related to ssh? But I push and pull using only https. And why can the new user push to my repo? I didn't add him as my collaborator.
Asked
Active
Viewed 154 times
1 Answers
3
user.name
and user.email
are not related to authentication at all. These are just fields written to commits made locally. Anyone can write anything for these fields and anyone can push commits declared as made by anyone.
You can think of those fields like an email signature: you write it when creating the email/commit and people can read it but it's just a part of the email/commit and anyone can write anything in the emails/commits they send/make.

grg
- 5,023
- 3
- 34
- 50
-
How do I actually logout and login with another account then? Why doesn't git ask me to enter my username and password again but instead it just logged me in automatically. – palapapa Dec 20 '20 at 13:28