How to configure Git username and email address
New users, before making a first commit to a repository, should configure a username and email address in git.
You can configure this data globally or per repository.
Global username/email configuration
If you have git installed locally you can open a terminal and run these two commands:
Set the username:
git config --global user.name "FIRST_NAME LAST_NAME"
Set the email address:
git config --glo]bal user.email "MY_NAME@example.com"
Verify your configuration. Usually git stores these settings in a .gitconfig
file in your home directory:
cat ~/.gitconfig
If you do not have git installed, you can create a .gitconfig
file in your home directory. The snippets below create one if it does not exist.
username := 'FIRST_NAME LAST_NAME'. email := 'MY_NAME@example.com'.
configFile := FileLocator home / '.gitconfig'. configFile exists ifFalse: [ configFile writeStreamDo: [ :aStream | aStream nextPutAll: ('[user] name = {1} email = {2}' format: { username . email }) ] ]
In case the file exists, or to check its content, you can directly inspect it.
FileLocator home / '.gitconfig'.
Checking the configuration
In case you have a git repository already created, the snippets below verifies if the email and username are set correctly.
repositoryName := 'YOUR_REPOSITORY'.
repository := IceRepository registry detect: [ :aRepository | aRepository name = repositoryName ]. [ repository repositoryHandle defaultSignature ] on: LGit_GIT_ENOTFOUND, LGit_GIT_ERROR do: [ :e | 'Username or email address not configured!' ]
Repository-specific username/email configuration
If you have git installed locally you can open a terminal, go to the repository directory and run the following commands:
git config user.name "FIRST_NAME LAST_NAME"
git config user.email "MY_NAME@example.com"
To verify:
cat .git/config