Git Identity

Your identity in git can be tricky, especially if you have multiple ID’s (for example, one for your work and other for your public commits in github).

You can define your ID globally or per repository.

Global

You can define your identity globally with:

git config --global user.name "Bob"
git config --global user.email "bob@example.com"

Or simply by editing the file ~/.gitconfig. For example:

[user]
    email = bob@example.com
    name = Bob

Repository

You can change your identity only in the repository that you want:

git config user.name "Bob"
git config user.email "bob@example.com"

Or by editing the file .git/config inside of your repository and adding a user section. For example:

[user]
    email = bob@example.com
    name = Bob