Better commits with GIT - Different email addresses for different respositories

When people start using GIT, usually they signup in a service like github.com or bitbucket.org. To do so, they use their personal or business email accounts and then configure git clients accordingly with this.

The first thing you do when you start using GIT is to configure some basic variables in the GIT global environment. In other words, you setup your name and email address for all the projects you are going to work from now on.

This is how you do it unsing your terminal:

$ git config --global user.name "YOUR NAME"
$ git config --global user.email "YOUR EMAIL ADDRESS"

What does this means? Each time you do a commit, it will be signed with that information because it was configured in the global space.

This is good, right? Well it is, but if you are doing work stuff you should be signing your commits with your job's email, if you are doing personal stuff you should be using your personal information, or at least that's what I think.

To check those settings run this in your terminal:

$ git config --list

It's important to understand that GIT allows you to specify an email address on a per repository basis. Let's see how we do this.

Setting up your identity per repository.

The --global option will make this configuration visible to all the projects by default. You can override this setting project by project (if you are not doing it, you should).

If you use a graphical interface for your GIT repositories as Source Tree you can do it in the Settings -> Advanced Tab window, un-click "Use global user settings" and write down your information.

If you use a terminal, you can do this from your respository folder:

$ git config user.name "YOUR NAME"
$ git config user.email "YOUR EMAIL ADDRESS"

This information is stored in a .gitconfig file in your drive in the project folder. 

So double check this before starting a new project.

$ git config --list
user.name=Diego Sapriza

reviewd by @jorgesierra

No hay comentarios.:

Publicar un comentario