The user.name
and user.email
settings are not logins, in any way, shape, or form. (The credential.helper
setting is useful here, but just unsetting it is probably not right.)
Whenever you make a new commit (by, e.g., running git commit
), Git needs to know what user name and email address to put in the new commit. Git gets these by reading user.name
and user.email
at that time. That's all they're for: to set these in new commits.1
When you run git push
, you do (usually2) need to authenticate in order to send your new commits to some other Git repository. Git does not do this authentication. Git relies on other programs to do it. Those other programs include:
Web servers, via https
URLs: here, Git has to send a user name and password or PAT or some other secret to the web server. Git gets these from:
- the URL, if they're in the URL;
- a credential helper, which you may configure: Windows Git comes with a Windows-specific credential helper, macOS Git comes with a macOS-specific credential helper, and so on; or
- as a last resort, reading the user name and password from the keyboard.
Generally the right way to do this is with a credential helper. See the gitcredentials documentation and the specific credential helpers available for your particular Git installation. The problem with method #1 is that the password is visible right there in the URL by anyone looking at your computer; the problem with method #3 is obvious.
Unsetting the credential helper gets you the default for your system. This might not be the best thing to do. For Windows systems, see Remove credentials from Git and in particular VonC's answer here.
Secure Shell (SSH): here, Git simply runs the ssh
command. Windows systems come with their own ssh command these days, and Git-for-Windows comes with its own ssh command because the older Windows systems either lacked ssh entirely or provided an inadequate version, so on Windows systems, you must make sure that you configure and use the correct ssh (whatever that may be for your installation).
Since you are using an https://
URL, you will need to set up your credential system. If you wish to use ssh://
URLs, set up ssh.
1Note that git rebase
works by copying existing commits to new and (supposedly / intended-to-be) improved ones, so this too uses the settings: it's making new commits.
2One can set up a completely open, anonymous network where anyone can push anything at any time, but these are way too easy to abuse, so nobody does this in practice.