- Global Username Configuration: If you wish to change the global username, which applies to all your Git repositories, use the following command:
bashgit config --global user.name "new username"
Here, replace ""new username"" with your desired username.
- Repository-Specific Username Configuration: If you only want to change the username for the current repository, use the following command:
bashgit config user.name "new username"
This command only affects the configuration for the current repository.
Example
Suppose your original username is oldname, and you want to change it globally to newname. Enter the following command in the terminal:
bashgit config --global user.name "newname"
To verify whether the username has been set successfully, use the following command to check the current global username configuration:
bashgit config --global user.name
This will display newname, confirming the username has been updated successfully.
Additionally, if you want to use a different username projectname for a specific project, run the command in the root directory of that project:
bashgit config user.name "projectname"
Then, use:
bashgit config user.name
to confirm the username has been changed to projectname in that project.
2024年6月29日 12:07 回复