Friday, February 26, 2010

Git - check your config

If you are working with various projects; say work project and a sideline fun project or a open-source project for that matter. It's important that you get author name or author email id right when you commit.

You don't want your marty@localhost or xxx1337.AT.yahoo.COM to be showing in as author id in the corporate repository. Some opensource projects reject the commits if it is not from the registered email id.

You normally would have updated the git global config to a username/email id and forgot about it. So the tips is that

1) Set the global config to a name/id to the primary purpose you use that machine to, like home machine set to your personal id. office machine set to your office id.

git config --global user.name "My name is..."
git config --global user.email my_email@domain.com


2) Use git local config on sensitive projects to override global config settings. The easiest way to override to config is to run
git config user.name "My name for this project is..." on your local project folder.

You can edit the whole config file in vi/command line editor easily by using the command
git config --global -e
git config -e (to edit local config)


Finally use git config -l on the project folder to see merged config information that will be used when you commit.

N.B.
Install bash completion for git if you are not using it already.
http://justamemo.com/2009/02/09/bash-completion-along-with-svn-and-git-tab-completion/

Recommended Blog Posts