Working on many projects across multiple identities can be difficult to manage. This is a procedure that leverages git aliases to set an identity at the project level for any arbitrary project. This procedure also implements GPG-based commit signing, which establishes the following security features:
Without the global user name and user email, git would use the system’s hostname and username to make commits. Tell git to throw an error instead, requiring you to specify an identity for every new project.
Copy the public key block and add it to your Github or Gitlab settings. With the public key, Github and Gitlab can cryptographically verify your commits, placing a “Verified” label next to each. You may also want to enable Vigilant Mode, which will place an “Unverified” label next to commits that have not been signed (otherwise no label will be shown.)
Setting a git alias will give us a new git command to use to set the identity at a project level. This really is just a script that sets a particular global identity to the local config.