Git is a source-control tool used by software developers.
As I’ve mentioned I’m just learning the ropes of Git and as someone doing that I’m going through a lot of tutorials that have a lot of similar-looking tips. One in particular is the use of:
git config --global user.name "Your Name" git config --global user.email "email@example.com"
These are also the default instructions from GitHub after you’ve created a repository. On my system I will actually be working with 2 GitHub accounts and many repositories among the two accounts – essentially 1 for personal projects and 1 for business projects where some projects are open sources (public repository) and other portions are not (private repositories).
What I wanted was to just have those settings on a per-repository basis and not set them globally. Searching around I came across an article on the Git basics that shows how to edit your .git/config file directly to add a [user] section with the information you want. While that’s easy enough, I just wanted to know how to do it from the command line without making it global… fortunately for me, it turned out to be easy as cheese:
git config user.name "Your Name" git config user.email "firstname.lastname@example.org"
That’s right, just remove the ‘–global‘ and git will commit those values to the .git/config file for you (creating the [user] section if it’s missing). Keep in mind that Git determines the repository to write this information to based on the current directory you are in. It will hunt up the parent-directory-tree (including the current directory) for the first directory with a .git subdirectory, and then use that repository information. So you can be way down deep in a particular repository directory or at it’s root, but you can’t be “out” of it in a parent with no .git subdirectory.