Blog

Thoughts from my daily grind

Per project Git name & e-mail config

Posted by Ziyan Junaideen |Published: 20 May 2022 |Category: IT
Default Upload |

When a software engineer sets up their computer, one of the first things to do is set the name and e-mail as global Git configuration for commit signing. Sometimes we need to digress from the global configuration and set a custom name and e-mail on a per-project basis for Git commit signing. For example, last Monday, a company I joined provided me with an official e-mail account. I wanted to sign Git commits using my new e-mail address.

Setting up a project for Git commit signing with a particular name and e-mail can be done using:

  • The terminal using the Git command line (recommended)
  • Updating the .git/config file in your project directly

Update using Git command line

You can update the name and e-mail address used to sign Git commits. Using the command line is the recommended way to make such a configuration.

git config user.name "Ziyan Junaideen"
git config user.email "ziyan@jdeen.com"

Update using the Git config file

The Git config file is the .git/config file located in your Git project, which you can edit using your favourite editor. You would need to add a [user] section to set up your name and e-mail address for this particular Git repository.

⇒  cat .git/config
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    precomposeunicode = true

[user]
    email = ziyan@jdeen.com
    name = Ziyan Junaideen

Conclusion

We should always sign our Git commits using the appropriate name and e-mail. If your team provides an official e-mail, that is the e-mail you should sign your commits.

There may be many reasons to set up a per-project based name and e-mail for Git signing. However, the usual case is that you are joining a new team. Congratulations, good luck and happy hacking.

About the Author

Ziyan Junaideen -

Ziyan is an expert Ruby on Rails web developer with 8 years of experience specializing in SaaS applications. He spends his free time he writes blogs, drawing on his iPad, shoots photos.

Comments