Git Configuration (.gitconfig)

This is important to get right, as you alternate between working on your personal projects using your personal email, and work projects using your work email.

Main thread to look at, this is exactly my issue: https://stackoverflow.com/questions/52081171/git-using-the-wrong-email-for-push

Resources

Does the SSH key determine the author?

SSH or HTTP authentication is only used to check permission to push and have no correlation with commit authoring (unlike centralized VCS like CVS or SVN). Source

To sanity check, run

git config user.name
git config user.email

This should print out the desired name and email.

To set them up locally, run

git config user.name "Your Name"
git config user.email "your@email.com"

If you want something global, use the ~/.gitconfig file, or you do something like

git config --global user.name "Your Name"
git config --global user.email "your@email.com"

Which adds it to the config file.

How does this work with GitLab?

GitLab/GitHub will use the committer email to link commit author to GitHub/GitLab account.

Um, so what happens if the email is incorrect? Read more here

  • I am pretty sure GitLab/GitHub will just reject the commit, since it is linked to an invalid user, also see this

Apparently, you can also set your email to be private: https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-personal-account-on-github/managing-email-preferences/blocking-command-line-pushes-that-expose-your-personal-email-address